2011-07-28

命令行工具puttycyg

一直舍不得linux下的命令行工具,所以在笔记本上都一直装了cygwin。cygwin自带的命令行界面有太多不方便的地方,于是一直都是装了open ssh server,然后用putty登陆本机获得命令行界面。以前一直都可以用pageant加载私钥登陆不用输入密码。可是自从笔记本升级到windows 7,登陆windows的用户变为域用户之后,用pageant加载私钥登陆总是失败。为了不用输入密码获得命令行界面用了一下puttycyg,基本和 putty一样,只是多了一个connection type选项 cygterm,在命令行填入bash,port选项不用填就可登入。

2011-07-07

PI lookup use缺少权限

PI lookup user 在SAP ECC里不能读表LFBK,得到错误权限不够。查看LFBK的authorization group为FA,在表TBRG里查找到相应的 authorization object为S_TABU_DIS。

The table that contains all authorization objects is TOBJ.
The table that contains all activities is TACT.
The table that contains definition of all authorization groups is TBRG.

使用表AGR_USERS查找用户的role。查看一个authorization role 包含哪些authorization object,使用表 AGR_1251

2011-05-15

SAP NetWeaver Process Orchestration

SAP NetWeaver BPM
SAP NetWeaver BRM
SAP NetWeaver PI
三者合起来就是SAP NetWeaver Process Orchestration?

2011-05-02

PI message mapping editor shortcut

PI 7.0下的graphic message mapping editor下按住contro + shift,点击鼠标右键,有更多隐藏选项。更强大的快捷组合键是:control + shift + 0

2011-03-28

debug su01

se93,输入su01,得到su01的program名SAPMSUU0。然后se38,输入程序名,进入debugger。然后在debugger中设置断点,方法如下:
breakpoints -> breakpoints at ->breakpoints at Subroutine,在Program处填入saplsuu0,在Fmla处填入auth_check。

2011-01-20

解决jdownloader窗口不能选择正确的显示器

在办公室把笔记本和另外一个显示器连了起来,把笔记本设置为主显示器,画面扩展到大的显示器上。问题出在当把笔记本与外接显示器断开时,启动jdownloader后,jdownloader窗口不能正常显示在笔记本的屏幕上,似乎“显示”在已经没有连接的外接显示器上。鼠标移动到任务栏的图标上,可以看到窗口的缩略图,可就是不能把窗口拽回来。上次就遇到过这样的情况,当时刚好遇上电视开着,就把笔记本与电视连了起来,把窗口拽了回来。这次从办公室回来又发生这样的情况,以为重启启动一下电脑会解决这个问题。没想到重启后还是同样的问题,只好另寻出路。试了一下,这个方法管用。将鼠标移到任务栏的图标上,显示程序缩略图,然后单击右键出现菜单,选择移动,此时千万不要移动鼠标,而是移动左方向键,窗口就回来了!

这个问题好像和java有关,因为上次用的SAP download manager也是用java写的,也有同样的问题。

2011-01-15

XSLT 1.0处理分组

在处理一个接口映射时遇到需要分组的问题,因为发送方使用JDBC adapter从数据库抽取数据,SAP PI得到的数据结构为:
<row>
<column1/>
<column2/>
<column3/>
</row>
其中column1,column2,column3是JDBC adapter中SQL查询语句里select的表列。
这个问题通过graphic mapping的node function估计应该能解决,但没有例子和好的文档就先放弃了,改用XSLT来实现。现在读取出来的数据中有一列为INVOCIE_ID,同一个INVOICE下有多个line_item。为每一个INVOICE _ID应生成一个IDoc,所有具有相同INVOICE_ID的line_item要映射到同一个IDoc下。如果环境支持 XSLT 2.0,可以很方便的使用group-by解决分组的问题。试了一下SAP PI环境不支持group-by语句,只能使用XSLT 1.0支持的语句。一个名为Muenchian的方法颇为有名,使用了xsl:key语句和key函数,提高了XSLT处理分组的性能。一个简化的例子:
XML 源文件
<?xml version="1.0" encoding="UTF-8"?>
<MT_PTP_PURCHASEINVOICE>
    <row>
        <INVOICE_ID>12</INVOICE_ID>
        <INVOICE_CURRENCY>EUR</INVOICE_CURRENCY>
        <LINE_NUMBER>1</LINE_NUMBER>
    </row>
    <row>
        <INVOICE_ID>12</INVOICE_ID>
        <INVOICE_CURRENCY>EUR</INVOICE_CURRENCY>
        <LINE_NUMBER>2</LINE_NUMBER>
    </row>
    <row>
        <INVOICE_ID>13</INVOICE_ID>
        <INVOICE_CURRENCY>EUR</INVOICE_CURRENCY>
        <LINE_NUMBER>1</LINE_NUMBER>       
    </row>
   <row>
        <INVOICE_ID>13</INVOICE_ID>
        <INVOICE_CURRENCY>EUR</INVOICE_CURRENCY>
        <LINE_NUMBER>2</LINE_NUMBER>
    </row>
</MT_PTP_PURCHASEINVOICE>
XSLT 表单
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output indent="yes"/>
    <xsl:key name="mykey" match="row" use="INVOICE_ID"/>
    <xsl:template match="/">
        <doc>
            <xsl:for-each select="//row[count(. | key('mykey', INVOICE_ID)[1]) = 1]">
                <xsl:sort select="INVOICE_ID"/>
                <invoice>
                    <INVOICE_ID>
                        <xsl:value-of select="INVOICE_ID"/>
                    </INVOICE_ID>
                    <items>
                        <xsl:for-each select="key('mykey', INVOICE_ID)">
                            <xsl:sort select="LINE_NUMBER"/>
                            <line>
                                <xsl:value-of select="LINE_NUMBER"/>
                            </line>
                        </xsl:for-each>
                    </items>
                </invoice>
            </xsl:for-each>
        </doc>
    </xsl:template>
</xsl:stylesheet>

2011-01-11

XSLT下填充空白字符

今天遇到一个问题需要对一些字符串进行操作,以保证字符串达到给定的长度。如果字符串长度不够则在字符串后面添加空白字符来补齐。刚开始的想法是用给定的长度(m)减去字符串的长度(n),然后在字符串后面添加(m-n)个空白字符。不过去构造这(m-n)个空白字符还要额外想办法。google了一下xslt padding,更简洁的办法是添加超过给定长度的空白字符,然后用substring去取指定长度的字符串即可。同一个问题换一个思路方便多了。

如果要常用到,定义一个template,带两个参数。
<xsl:template name="pad">
<xsl:param name="str"/>
<xsl:param name="len"/>
<xsl:variable name="spaces"><xsl:text>                           </xsl:text></xsl:variable>
<!-- <xsl:text>在这里很重要,避免空白字符被过滤掉 -->
<xsl:value-of select="substring(concat($s, $spaces), 1, $len)"/>
</xsl:template>

需要时调用这个template即可:
<xsl:variable name="var">
<xsl:call-template name="pad">
<xsl:with-param name="str" select="concat(firstname, ', ', name)" />
<xsl:with-param name="len" select="10" />
</xsl:call-template>
</xsl:variable>

更灵活一些的template,'padVar' 是要填充的字符, 'length' 是给定的长度。
在前面插入,右对齐:
<xsl:template name="prepend-pad">
<!-- recursive template to right justify and prepend-->
<!-- the value with whatever padChar is passed in   -->
<xsl:param name="padChar"> </xsl:param>
<xsl:param name="padVar"/>
<xsl:param name="length"/>
<xsl:choose>
<xsl:when test="string-length($padVar) &lt; $length">
<xsl:call-template name="prepend-pad">
<xsl:with-param name="padChar" select="$padChar"/>
<xsl:with-param name="padVar" select="concat($padChar,$padVar)"/>
<xsl:with-param name="length" select="$length"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring($padVar,string-length($padVar) - $length + 1)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

在后面插入,左对齐:
<xsl:template name="append-pad">    
<!-- recursive template to left justify and append  -->
<xsl:param name="padChar"> </xsl:param>
<xsl:param name="padVar"/>
<xsl:param name="length"/>
<xsl:choose>
<xsl:when test="string-length($padVar) &lt; $length">
<xsl:call-template name="append-pad">
<xsl:with-param name="padChar" select="$padChar"/>
<xsl:with-param name="padVar" select="concat($padVar,$padChar)"/>
<xsl:with-param name="length" select="$length"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring($padVar,1,$length)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

2011-01-10

galaxy s 的几个常用按键操作

拿着galaxy s手机还没翻看过说明书,不知道这里列出的按键操作是否在说明书中已被提及。
  • 快速重启:同时按住 加大音量和电源键 5秒钟。这样不必按住Power键,选择关机,然后再按Power开机。
  • 调出搜索框:长按住菜单键
  • 切换任务:长按住Home键
  • 在联系人里,往右滑动,拨打联系人电话,往左滑动,发送短信

2011-01-06

启动android SDK manager

Samsung的galaxy s到了,免不了要折腾一下。在笔记本上装了android的SDK,选择的是推荐的installer安装文件。安装完后竟然不能启动SDK manager。点击后没有任何反应,在命令行下执行android.bat update sdk得到错误提示:
'java -jar lib\archquery.jar' is not recognized as an internal or external command,
operable program or batch file.
ERROR: SWT folder '' does not exist.
Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
google了一番,禁用了windows 7的UAC,用管理员权限执行命令,都是同样的结果。既然变量ANDROID_SWT没有被赋正确的值,直接在
for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
后面加上了:
set swt_path=lib\x86_64

在执行android.bat得到错误提示就比较有帮助了:
Cannot load 64-bit SWT libraries on 32-bit JVM
因为windows操作系统是64位的,而我装的JDK是32位,为了运行SAP PI 7.0的客户端,因此64位的swt.jar不能加载。修改为:set swt_path=lib\x86 就能正常启动了。

新手机Samsung Galaxy I9000的版本

新手机到手后先用Samsung的Kies更新到到了Anroid 2.2。键入*#1234#得到firmware信息:
PDA: I9000BOJPB (This is android and all the applications that come with it.)
PHONE: I9000BOJP3 (This is the firmware of the wireless chipset of the device and will operate you WiFi, Blutooth and 3G/2G/GSM connections. 这就是常说的Radio ROM)

CSC: I9000GDTMJP6 (Customer Specific Customization)
build info: 2010.11
这个在刷机的时候检查版本会用到。

soft reset: 按住机身右边电源键
hard reset:按住 VolumeUP+Home+Power,选择“wipe data/factory reset”,恢复到默认设置 (我的手机的这个组合键好像被禁用了,不管用!)

*#1234# : SW Version
*#2222# : HW Version
*#0842# : Vibrator Test
*#0289# : Buzzer Test
*#0228# : Battery Statue

2011-01-04

导入以前的posts

圣诞节前就把wordpress里的帖子导出来,并用wordpress2blogger转换成了blogger的格式,可是在导入时遇到一个问题:页面一直在显示导入的进度条,也不给出任何出错信息。用不同的浏览器在不同的时间去导入帖子都是同样的问题,请教了一个也把wordpress转换到blogger朋友还是没有解决问题,于是把这个事先搁了下来。今天突然想起用我的另外一个google account来创建一个blogger帐号来测试一下。不想在新的blogger账户下导入没有遇到任何问题。原来这个问题和我在同一个google account下有多个blogger账户有关。我其中的一个blogger账户里已经包含部分将导入的帖子,因此导入就不能完成。这应该是导入程序会检测在这个google account下的所有blogger账户里是否包含要导入的帖子,如果有,则导入停止。值得改进的是,应该给出一个对用户更友好的信息。

2010-12-16

XML Tagung in Stuttgart

Xing收到了明年3月1日在斯图加特举行的一个XML会议的邀请,其中的一名报告者为Dr. Michael Key。如果和XML打过些交道的人想必都听说过这个名字。他参与了XSLT 2.0和XPATH 2.0标准的制定,有自己实现的XSLT processor SAXON,并且写了多本关于XPATH和XSLT的书籍,如XPath 2.0 Programmer's Reference,XSLT 2.0 Programmer's Reference,XSLT 2.0 and XPath 2.0 Programmer's Reference,是一位名副其实的XML专家。他在很多mailing list也很活跃,常常参与有关XSL的讨论和解答有关的问题。本来有个Stuttgart的项目找人,但因为时间上不合适放弃了,否则倒是想去凑个热闹,听听这些站在XML技术最前沿的人能带来什么新鲜的东西。不过想到参加这个会议的报名费(包括一顿自助午餐)也不便宜,普通250欧元,有折扣券的180欧元,也不觉得不参加有多大遗憾 :) 。

2010-12-14

在XSLT中调用Java函数

在为客户实现一个sap PI的interface时,用XSLT去生成IDoc的XML文件形式,通过sap PI的IDoc adapter发送IDoc。由于客户现在用SAP替代了旧的Oracle系统,需要映射一些如Cost Centre和Profit Centre的东西,映射所需的表在SAP PI系统中。要读取数据库中的东西借助XSLT不容易实现,只能用Java。在Java代码中使用SAP JCO读取并返回了正确的值,但是在XSLT中调用JAVA函数却大费了一番周折,问题主要出在该如何声明自定义的命名空间才能使XSLT processor能找到编译好的Java class文件,以调用Java类中定义的函数。
当XSLT文件和Java class文件位于一目录下,经过测试,在Altova XML Spy下,命名空间需要声明为:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:myns="java:Test" exclude-result-prefixes="myns">
其中需要注意的是在xmlns:myns="java:Test" exclude-result-prefixes="myns"中,java不能省掉,Test为Java class的名字,否则Altova 的XSLT processo找不到声明的Java class,会返回ClassNotFound exception。
而在SAP PI 7.0环境下,声明自定义的命名空间必须去掉“java:”,否则也会出现找不到Java class的错误。
示例:
XSLT文件
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:myns="java:Test" exclude-result-prefixes="myns">
 
<xsl:template match="/">
<root>
<text><xsl:value-of select="myns:foo(‘hello’, ‘world’)" /></text>
</root>
</xsl:template>
</xsl:stylesheet>
Java class
public class Test {
     public static String foo(String str1, String str2) {
     return str1 + “ ” + str2 ;
     } 
}

2010-12-13

XPATH点滴

XPATH 1.0中一个XPATH表达式返回一个节点的集合(node set),因为是一个集合,所以不存在节点顺序的概念。而在XPATH 2.0中一个表达式返回的则是一个节点序列(sequence of nodes),顺序为document order。

/ 符号:以前基本上认为就是在轴上分隔不同的节点。更广义的理解是这是一个高阶的运算符。比如$EXP1和$EXP2 分别为两个节点集合,那么$EXP1/$EXP2表示对$EXP1中的每一个节点对$EXP2求值,$EXP1/$EXP2的值即为:对$EXP1中每个节点对$EXP2求值的集合。

对轴的理解:轴实际上是一种节点间一对多的映射,可以把轴理解为一种函数,输入为一个单个节点,输出为与该节点有某种关系的节点的集合。

(@code,"N/A")[1]:如果code属性的值不为空,那么这个表达式的值即为code属性的值,否则返回”N/A”。因为当code属性的值为空时,通过运算符逗号 “,” 创建的sequence只有一个item即”N/A”,筛选条件[1]选择sequence中第一个元素。

2010-12-10

实物恋

早上起来打开电视正播放ARD的新闻。很多德国人对柏林墙都是恨之入骨,可是新闻里正报道的一位在柏林生活的美国人对柏林墙却有性喜好。她先是数年前在法国巴黎与埃菲尔铁塔成亲,之后又辗转到柏林,爱上了残余的柏林墙。报道之后采访了一位医学教授,据说德国约有50多名性取向目标为实物。有同性恋,没想到还有实物恋。刚好赶上这条新闻是节目的最后一条,另外估计这个确实罕见,ARD的播音员已经忍不住笑着说了结束语。新闻节目消音后,屏幕上还能看到这位一向严肃的女播音员已经大笑不止了。这和我们的播音员在播音结束后还正襟危坐等待画面切开截然不同。

2010-12-09

不能加载SAPJCORFC

操作系统为Windows 7 64bit Enterprise,JDK版本为32bit的"1.5.0_22"。按照sapjco2的说明已经把sapjcorfc.dll和librfc32.dll复制到目录c:\system\windows\system32,可是仍然得到错误:
Exception in thread "main" java.lang.ExceptionInInitializerError: JCO.classInitialize(): Could not load middleware layer 'com.sap.mw.jco.rfc.MiddlewareRFC'
JCO.nativeInit(): Could not initialize dynamic link library sapjcorfc [no sapjcorfc in java.library.path]. java.library.path [C:\Program Files (x86)\Java\jdk1.5.0_22\bin;.;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\Java\jdk1.5.0_22\bin; C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\ThinkPad\Bluetooth Software\;C:\Program Files\ThinkPad\Bluetooth Software\syswow64;C:\Program Files (x86)\Windows Live\Shared;c:\cygwin\bin;C:\Users\dingjun.jia\Documents\Data\UnxUtils\usr\local\wbin;C:\Users\dingjun.jia\Documents\Data\projects\o2 SAP\cmd;]
    at com.sap.mw.jco.JCO.<clinit>(JCO.java:820)
    at JM_I025B.countVendorData(JM_I025B.java:26)
    at JM_I025B.main(JM_I025B.java:10)
很明显是找不到sapjcorfc.dll,所以不能加载。把sapjcorfc.dll和librfc32.dll这两个文件复制到jdk的bin目录下,也就是上面错误中的第一个目录中,就能正确加载了。难道java只在目录列表中的第一个目录去寻找。

2010-11-23

PI 7.1与PI7.0的比较

Name changes PI 7.0 -> PI 7.1

Integration Repository (IR) -> Enterprise Service Repository (ESR)
message interface -> service interface
interface mapping -> operation mapping
business service -> business component

Features of PI 7.1 over PI 7.0

a) Repository Objects

  • Service Registry (SR) is to support publishing, classifying, discovering services.
  • Service Interfaces (SI) may contain several operations where each operation describes one communications (Synchronous / Asynchronous). The various attributes are Category (I/O/A), Mode(S/A), Interface Pattern & Operation Pattern
  • Interface patterns is a new attribute of a service interface that describes the type of communication that is to be executed on the message (Stateless/ Stateless Xi 3.0 Compatible / TU&C/C and Stateful)
  • Operation Patterns depends on Interface patterns (Normal / Commit/ Rollback / Confirm/Tentative Update/Compensate)
  • SAP Global Data type (GDT) is introduced to have business semantics in order to replace SAP Core DT
  • Folders are introduced to organize projects and interfaces which have access authorizations
  • We can use either XML toolkit / JDK 1.5 toolkit for JAVA and XSLT Mapping.

b) Mapping Enhancements


  • We can set Failure Behavior in fix values and value mapping (Return initial value/Default/Exception)
  • Output of fields and functions can be used for multiple target fields for Reusable / Better Runtime Performance
  • Tool support to adjust the mappings after the structure changes to avoid structural inconsistencies.
  • Storing intermediate Results in a variable can be possible and can be reused.
  • Complete copy of XML sub trees is possible
  • Parameterized mapping is useful for Channel Lookup and Reuse of multiple mapping in Interface Determinations and to transfer content of Container in UDF.
  • Function Libraries is useful for reuse of UDF and enhanced portability of UDF.
  • Graphical Support of RFC Lookup and JDBC Lookup is available.
  • Importing SQL Tables Meta Data is possible

c) ccBPM


  • Step Groups - Set of steps that can be reused by embedded in Integration Process across SWCV. Step Parameters can also be used in step groups.
  • Configurable Parameters - Defined in Integration process and the values can be used assigned in ID. Here Agents, Communication channel and simple data type can be used as parameters.
  • User Interaction - User Decision Step in Integration Process with an agent configured in ID is used to get the workflow message to make a decision

d) Configuration Objects


  • Web Service Reliable Messaging WS-RM for Asynchronous messaging is configured in Sender Agreement and Communication Channel for a considerable level of reliability and security.
  • Principal Propagation based on Security Assertion Markup Language (SAML 1.1) can be configured in WS adapter. It means user is securely propagated from a sender system to receiver systems. An authorization check in receiving system based on original user.
  • Advanced Adapter Engine (AAE) is used to increase the performance of message processing by eliminating the need for ABAP stack during the process.
  • Reusable Receiver Rules for logical routing can be used in different Receiver Determination.
  • Cache Notification function is enhanced to analyze the possible error.
  • XML Payload validation is possible in sender and Receiver agreement.
  • Publish the sender agreement in Service Registry for web service Client and provider connected to IS.
  • Centralized administration and monitoring is done by SAP NetWeaver Administrator.
  • Message Packing enables processing bulk messages in one service call and reduce context switches