创建IDOC:
第三步:WE81 第四步:WE82 管理IDOC:
消息配置: 官方介绍:
An IDoc is simply a data container that is used to exchange information between any two processes that can understand the syntax and semantics of the data. IDoc is not a process. An IDoc Type is SAP's format for data being moved between
applications. Essentially, SAP has defined what a sales order,
financial statement, invoice, etc will look like electronically.
This includes how fields are grouped together (segments), the order
and hierarchy of these groupings, and the format of each individual
field.
If you're familiar with EDI at all, then an IDoc will look
very familiar to you. Nearly everything you're used to is there:
from segment name to allowable codes to min/max occurs.
It is important to note that an IDoc Type is really just a
structure defined on the system and given a name (i.e., ORDERS04).
An actual IDoc, however, consists of data, which fits within the
defined structure of the IDoc Type. This IDoc is identified by a
number rather than by a type.
Creation of IDOCs
Transaction code: WE30
Steps of Defining Segment
Creating Segment : Tcode - WE31 Creating Message Type : Tcode - we81
Assigning Message type to Idoc type: Tcode - we82
Process
The two processes for IDoc are Outbound Process and Inbound
Process.
Outbound Process
When the data is sent out from the system, the process is called Outbound Process and the IDoc is known as Outbound IDoc. Inbound Process
When the data is coming in, the process is called Inbound Process and the IDoc is known as Inbound IDoc. Outbound Process (Sending System) Steps :
1) Goto Tcode SALE:
Creating the logical system Click on Sending & Receiving Systems à Select Logical
Systems--Here Define the Logical Systems
Go for New Entries 1)
Assigning Client to the Logical System: Select Assign Client to Logical Systems
Client
Logical System and also Client
System Save this Data.
Step 2) For RFC Creation: Goto Tcode SM59 and Click on create Button RFC Destination Name should be same as partner's logical system name and case sensitive to create the ports automatically while generating the partner profiles Give the information for required fields: RFC Destination Connection type Target Host System
No
Client
User Password Save this & Test it and Remote Login Step 3) Goto Tcode BD64: Click on the change button>Click on the create model view Short Text: model view
Technical Name: LMOD
Save this & press ok Select just created model view Name: "LMOD"
Goto add message type Model Name
Sender
Receiver Message type: ZAZHARMESS Save and press Enter
4) Goto Tcode BD82:
Give Model View Partner system Execute this by pressing F8 It will gives you sending system port No: 5) Goto Tcode BD64: Select the model view Goto >Edit >model view > Distribute Press ok & Press Enter. Run your Zprogram
REPORT
SPAN { font-family: "新宋体"; font-size: 10pt; color: #000000;
background: #CCE8CF; } .L0S31 { font-style: italic; color: #808080;
} .L0S32 { color: #3399FF; } .L0S33 { color: #4DA619; } .L0S52 {
color: #0000FF; } DATA:
DATA: imas_data icom_con PARAMETERS: * SELECT *Master wamas_con-rcvprt wamas_con-rcvprn wamas_con-idoctp wamas_con-mestyp * LOOP ENDLOOP. CALL COMMIT 6) Verifying Transfer of IDOCs Tcode - we05
ALE/IDOC Status Codes (outbound): 01> IDoc Added
30 > IDoc ready for dispatch 29 >Error in ALE service Layer 12 >Dispatch ok 03 > Data passed to port ok. Inbound Process (Receiving System) Steps:
Do the same step as you did in sending system 9 |9 S! c+ a > >
> >
> >
>
1) Goto Tcode - we57 Assign function module to IDoc type
Module: Function module Basic type: Message type: Direction: 2 (inbound) 2) Creating Inbound process code - we42 3) Verifying Idoc List Tcode - we05 4) ALE/IDOC Status Codes (Inbound):
50 >IDoc Added
51 >Application Document not posted
64 >IDoc ready to be transferred to application
62 >IDoc passed to application 53 ----------------------实例------------------------------------------------ 简而言之,IDOC是类似XML的一种SAP系统与其他系统的一种集成工具。 假设I04和I02是同一个集团下两个不同子公司的SAP系统,I04需要将其采购订单信息及时发送给I02。下面简单介绍IDOC的设置步骤,为了避免混淆,我的命名都比较特别。 1,设置IDOC Type.
保存后用SE12查看你将发现,系统自动添加了YPOHEAD和YPOITEM两个结构,每个字段都成了CHAR类型,长度就是WE31中的EXPORT
LENG。
2,创建Message Type.
程序的思路就是,把每个IDOC结点按字符串形式逐个添加,而字符串的添加次序自然也体现了IDOC结点间的逻辑关系。代码如下, DATA: ls_pohead TYPE ypohead,
CLEAR ls_edidc.
*系统根据下面4行即可与WE20设置关联起来 ls_edidc-mestyp = 'YPO'. ls_edidc-idoctp = 'YPOIDOC'. "IDOC Type
ls_edidc-rcvprn = 'I02LS'.
ls_edidc-rcvprt =
'LS'.
*添加IDOC结点 CLEAR lt_edidd.
lt_edidd-segnam = 'YPOHEAD'."结点名称 lt_edidd-dtint2 = 0.
CLEAR ls_pohead. ls_pohead-ebeln = '4001122334'.
ls_pohead-bukrs = '0400'. ls_pohead-bedat = '20090630'.
lt_edidd-sdata = ls_pohead. "结点内容 APPEND lt_edidd. CLEAR lt_edidd.
lt_edidd-segnam = 'YPOITEM'. lt_edidd-dtint2 = 0.
CLEAR ls_poitem. ls_poitem-ebeln = '4001122334'. ls_poitem-ebelp = '0001'. ls_poitem-matnr = '000000000000004527'.
ls_poitem-menge = '3'. ls_poitem-meins = 'ST'. lt_edidd-sdata = ls_poitem.
APPEND lt_edidd.
CLEAR lt_edidd.
lt_edidd-segnam = 'YPOITEM'. lt_edidd-dtint2 = 0.
CLEAR ls_poitem.
ls_poitem-ebeln = '4001122334'.
ls_poitem-ebelp = '0002'.
ls_poitem-matnr = '000000000000009289'. ls_poitem-menge = '5'.8 P( Y; S' _9 | ls_poitem-meins = 'M'. lt_edidd-sdata = ls_poitem. APPEND lt_edidd. CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
IF sy-subrc <> 0. ELSE.
'; sender partner',ls_edidc-sndprn. ENDIF.
---------------------------------------实例----------------------------------Inbound Idoc 这里将继续沿用上篇文章的例子,讲述I02对接收到的采购订单信息进行的相关处理。
1,创建IDOC Type和Message Type.
与上篇Outbound Idoc中的前两个步骤完全一样。 2,创建一个function:Y_IDOC_PO_PROCESS. 当IDOC设置完毕之后,SAP可以自动调用该Funtion
Module处理IDOC。所以这个函数的接口都是规范的。
下面步骤中将介绍的tcode:BD51中可以查询到很多Inbound
Function,比如IDOC_INPUT_BBP_IV,可参照创建我们的接口。
接下来就可以写入我们的代码,根据IDOC内容,创建相应的销售订单。为了简化,这里我们仅仅将其存到数据库表里面,请先创建两个表Y02_POHEAD和Y02_POITEM,字段参考WE31中的YPOHEAD和YPOITEM。然后写入下面代码: DATA: lv_subrc LIKE sy-subrc,
ls_pohead TYPE y02_pohead, CLEAR idoc_contrl.
READ TABLE idoc_contrl INDEX 1.
ENDIF. LOOP AT idoc_contrl. CLEAR: ls_pohead, lt_poitem[]. LOOP AT idoc_data WHERE docnum = idoc_contrl-docnum. CASE idoc_data-segnam. 3,在BD51中注册我们的Function Module.
在编辑状态下,点击New Entries,填入函数名Y_IDOC_PO_PROCESS,Input Type=1即可。 4,在WE57中将Function Module与IDOC Type/Message Type关联
点击New Entries,Function Module输入Y_IDOC_PO_PROCESS,其下的Type填写F;IDOC Type下的Basic Type填写YPOIDOC;Message Type填写YPO;Direction填写2(Inbound)。 5,WE42,创建Inbound Process Code.
注意该步骤必须在BD51和WE57之后,否则将出现错误提示。
创建新条目,Process Code输入YPC_PO,在Option ALE下选择Processing with ALE
service,在Processing Type下选择function module。保存后,在随后的窗口中,输入Inbound
Module为Y_IDOC_PO_PROCESS。
6,WE20,维护Partner Profiles.
首先确保SALE中已经维护好了对应于接收方的Logical
System,假设名称为I04LS。(WE05查看您的Inbound IDOC,
均可看到其Partner名称,这就是我们所需要的。本步骤与上篇的WE20类似,不同的是,这里是维护从I04LS过来的Inbound
Parameters。Message Type输入YPO,Process Type输入YPC_PO,然后选中"Trigger
immediately"即可。
7,至此,我们的设置已经完毕。系统接收到从I04传来的IDOC后即会立刻处理。
同时,各位针对上篇做过练习的朋友,系统中应该会遗留几个处于出错状态的IDOC吧?可以用BD87,在主界面上选中结点YPO后,点击Process按钮,一次性处理。处理前,顺便在SE37中打开Y_IDOC_PO_PROCESS并设置几个断点即可调试。
补充:
(1)如果状态码为56,则应该是您的WE20没设置好;
(2)由于上面代码中控制了不能插入同样的采购单号,所以只有一个Inbound IDOC将处理成功(状态码53),其余将失败(状态码51)。只要新发送的IDOC赋于不同的采购单号即可避免。 (3)Outbound的状态码是0-50,03代表OK;Inbound的状态码则是50-99,53代表OK。
|
|