SAP IDOC开发(转)
第一步:WE31 创建IDOC所包含的字段.
第二步:WE30 创建IDOC 把Segment分配给IDOC
第三步:WE81 创建信息类型
第四步:WE82 把IDOC类型与信息类型对应.
WE02 显示IDOC,可以根据时间,IDOC类型查找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.
IDocs are stored in the database.
IDocs are independent of the sending and receiving systems.
IDocs are independent of the direction of data exchange.
Creating Segment : Tcode - WE31
When the data is sent out from the system, the process is called Outbound Process and the IDoc is known as Outbound IDoc.
When the data is coming in, the process is called Inbound Process and the IDoc is known as Inbound IDoc.
Creating the logical system
Go for New Entries
System Name : LOG2 prescription: Receiving System
Press Enter & Save it will ask for Request if you want new request create new request or press continue for transferring the objects.
Assigning Client to the Logical System:
Logical System : LOG1
and also
System : LOG2
Goto Tcode SM59 and Select R/3 Connects
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 : LOG2
Connection type : 3
Target Host : sappdc.wipro.com
User : Login user name5 s6 q6 o; y- O: [ g+ }- Z
Password :
Save this & Test it and Remote Login
Click on the change button>Click on the create model view
Save this & press ok
Select just created model view
Goto add message type
Receiver : LOG2
Message type: ZAZHARMESS
Give Model View : LMOD
Partner system : LOG2
Execute this by pressing F8
It will gives you sending system port No: A00000000089 (Like)
Select the model view
Goto >Edit >model view > Distribute
Press ok & Press Enter.
Run your Zprogram
matnr LIKE mara-matnr,
mtart LIKE mara-mtart,
END OF imara.
DATA: wamas_con LIKE edidc,
imas_data LIKE edidd OCCURS 0 WITH HEADER LINE,
icom_con LIKE edidc OCCURS 0 WITH HEADER LINE.
PARAMETERS: e_matnr LIKE mara-matnr,
e_msgtyp LIKE edidc-mestyp,
e_rcvprn LIKE edidc-rcvprn.
* retrive app. data from DB
SELECT matnr mtart FROM mara INTO TABLE imara
WHERE matnr = e_matnr.
*Master idoc control record
wamas_con-rcvprt = 'LS'.
wamas_con-rcvprn = e_rcvprn.
wamas_con-idoctp = 'ZAZHARIDOC'.
wamas_con-mestyp = e_msgtyp.
* master idoc data records
LOOP AT imara.
imas_data-segnam = 'ZAZHARSEG'.
MOVE imara TO imas_data-sdata .
APPEND imas_data.
ENDLOOP.
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
master_idoc_control = wamas_con
TABLES
communication_idoc_control = icom_con
master_idoc_data = imas_data.
COMMIT WORK.
ALE/IDOC Status Codes (outbound):
30 > IDoc ready for dispatch
29 >Error in ALE service Layer
12 >Dispatch ok
03 > Data passed to port ok.
Do the same step as you did in sending system
9 |9 S! c+ a {
> Creating IDoc
> Creating Message Type
> Defining the Logical System
Module: Function module
Basic type:
Message type:
Direction: 2 (inbound)
3) Verifying Idoc List Tcode - we05
62 >IDoc passed to application
53 >Application Document posted
简而言之,IDOC是类似XML的一种SAP系统与其他系统的一种集成工具。
假设I04和I02是同一个集团下两个不同子公司的SAP系统,I04需要将其采购订单信息及时发送给I02。下面简单介绍IDOC的设置步骤,为了避免混淆,我的命名都比较特别。
(1) WE31,创建segment,类似于创建XML的结点及结点属性。
(2) WE30, 创建IDOC Type,定义结点间的相互逻辑关系.
先切换到编辑状态,然后点击New Entries,输入YPO即可。
(2) WE82,,关联Message Type和IDOC Type.
设置了这么多,真累啊,总算可以写程序了,是不是很开心呢?
程序的思路就是,把每个IDOC结点按字符串形式逐个添加,而字符串的添加次序自然也体现了IDOC结点间的逻辑关系。代码如下,
*系统根据下面4行即可与WE20设置关联起来
ls_edidc-mestyp = 'YPO'. "Message Type
lt_edidd-segnam = 'YPOHEAD'."结点名称
CLEAR ls_pohead.
ls_pohead-bukrs = '0400'.
lt_edidd-sdata = ls_pohead. "结点内容
APPEND lt_edidd.
lt_edidd-segnam = 'YPOITEM'.
CLEAR ls_poitem.
ls_poitem-ebeln = '4001122334'.
ls_poitem-ebelp = '0001'.
ls_poitem-menge = '3'.
ls_poitem-meins = 'ST'.
lt_edidd-segnam = 'YPOITEM'.
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.
master_idoc_control = ls_edidc "Export
TABLES
communication_idoc_control = lt_edidc "Import
master_idoc_data = lt_edidd "Export
EXCEPTIONS"
IF sy-subrc <> 0.
'; sender partner',ls_edidc-sndprn.
---------------------------------------实例----------------------------------Inbound Idoc
与上篇Outbound Idoc中的前两个步骤完全一样。
2,创建一个function:Y_IDOC_PO_PROCESS.
接下来就可以写入我们的代码,根据IDOC内容,创建相应的销售订单。为了简化,这里我们仅仅将其存到数据库表里面,请先创建两个表Y02_POHEAD和Y02_POITEM,字段参考WE31中的YPOHEAD和YPOITEM。然后写入下面代码:
ls_pohead TYPE y02_pohead,
RAISE wrong_function_called.
ENDIF.
LOOP AT idoc_contrl.
CLEAR: ls_pohead, lt_poitem[].
LOOP AT idoc_data WHERE docnum = idoc_contrl-docnum.
CASE idoc_data-segnam.
CLEAR: ls_chead, ls_pohead.
ls_chead = idoc_data-sdata.
WHEN 'YPOITEM'.
ls_citem = idoc_data-sdata.
lv_subrc = 0.
INSERT y02_pohead FROM ls_pohead.
INSERT y02_poitem FROM TABLE lt_poitem.
lv_subrc = sy-subrc.
ELSE. "订单号已经存在
lv_subrc = sy-subrc.
IF lv_subrc = 0.
CLEAR idoc_status.
idoc_status-docnum = idoc_contrl-docnum.
idoc_status-status = '53'. "IDOC处理成功
ELSE.
idoc_status-docnum = idoc_contrl-docnum.
idoc_status-status = '51'. "IDOC不成功
idoc_status-msgid = 'YMSG'.
ENDLOOP.
在编辑状态下,点击New Entries,填入函数名Y_IDOC_PO_PROCESS,Input Type=1即可。
点击New Entries,Function Module输入Y_IDOC_PO_PROCESS,其下的Type填写F;IDOC Type下的Basic Type填写YPOIDOC;Message Type填写YPO;Direction填写2(Inbound)。
(2)由于上面代码中控制了不能插入同样的采购单号,所以只有一个Inbound IDOC将处理成功(状态码53),其余将失败(状态码51)。只要新发送的IDOC赋于不同的采购单号即可避免。
SAP IDOC开发(转)的更多相关文章
- [SAP ABAP开发技术总结]IDoc
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- SAP-ABAP系列 第二篇SAP ABAP开发基础
第二章SAP ABAP开发基础 1.ABAP数据类型及定义 ABAP程序中共包含8种基本数据类型定义, 类型名称 描述 属性 C Character Text (字符类型) 默认长度=1,默认值 = ...
- 【PI系列】SAP IDOC发送状态03,PI没有收到消息的解决办法
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[PI系列]SAP IDOC发送状态03,PI没 ...
- 【ABAP系列】SAP ABAP 开发中的SMARTFORMS 参数
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP 开发中的SMA ...
- SAP CRM 开发学习资料和教程整理【不定时更新】
本文链接:http://www.cnblogs.com/hhelibeb/p/6276929.html 首先是SAP网站上面的相关内容 SAP Customer Relationship Manage ...
- SAP IDOC 通过采购订单输出消息生成销售订单
题记: 在网络上看到一篇类似的公众号文章,叫<通过IDoc逐步指导PO&SO集成>,个人觉得整个配置过程中还是少了一些重点配置,也少了说明整个功能的核心逻辑,那么,趁着这个机会,就 ...
- ABAP开发顾问必备:SAP ABAP开发技术总结
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- [SAP ABAP开发技术总结]ALV
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- [SAP ABAP开发技术总结]OPEN SQL
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
随机推荐
- roundabout插件使用(3d旋转轮播图)兼容IE8
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- js组合继承和寄生组合式继承比较
本文是原创文章,如需转载,请注明文章出处 1.js中实现组合继承(B继承A): function A(name){ this.name = name; this.ary = ["AA&quo ...
- 日常积累之JSON.stringify和JSON.parse substr
1.substr(start,len) 从字符串中读取内容,第一个参数是读取的首位置,如果为负数,则从末尾倒数计数. 第二个参数是要读取的长度. eg: var str = "silence ...
- Java 中的 request 和response 区别
1.response 属于重定向请求: 其地址栏的URL会改变: 会向服务器发送两次请求: 2. request 属于请求转发: 其地址栏的URL不会改变: 向服务器发送一次请求: 举一个区分它们的简 ...
- python中在同一个位置输出数据
import sys, time def print_data(): for i in range(5): sys.stdout.write(str(i) + '\r') time.sleep(1) ...
- Jquery动态操作checkbox
问题的由来:html页面中使用checkbox给新建用户授权,然后提交到后台服务器,完成给用户授权.用户授权完成之后,如果用户的权限发生改变管理员需要修改多个用户的权限或查看某用户的权限,点击不同的用 ...
- Android Studio 如何切换sdk
选择File-->Project Structure 弹出框中选择Project 看到中间的Project SDK项. 点击Edit或者New 然后就可以选择Build target 和Ja ...
- DFD
- nmon--非常棒的LINUX/AIX性能计数器监测和分析工具
转自51Testinghttp://bbs.51testing.com/viewthread.php?tid=116526 经常看到很多人讨论说loadrunner对linux/aix的性能监测太少, ...
- FT部署图