IDOC创建、发送、接收及程序代码[转]
什么是IDOC,以及IDOC的步骤
创建IDOC:
第一步:WE31 创建IDOC所包含的字段.
第二步:WE30 创建IDOC 把Segment分配给IDOC
第三步:WE81 创建信息类型
第四步:WE82 把IDOC类型与信息类型对应.
第五步:WE57 Assign Message & Idoc Type to a Function Module for Data Process
第六步:SM59 Define a RFC connection for Idoc transfer
第七步:WE21 Define a Port ( Assign a RFC destination which created in SM59 )
第八步:WE41/42 Creat Process Code
第九步:WE20 Define a Partner Profiles( Also creat a Outbound parameters with Port, or Inbound parameters with Process code )
管理IDOC:
WE02 显示IDOC,可以根据时间,IDOC类型查找IDOC,查看成功,出错信息。
WE46 IDOC管理(出\入)
WE60 IDOC类型文档(可以查看IDOC结构,和每个字段的描述.
WE19 根据IDOC号进行IDOC处理,可以修改IDOC值进行补发动作,处理分为内向和外向。
消息配置:
WE20 配置伙伴消息进和出IDOC类型
WE21 配置伙伴。
官方介绍:
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.
- In the SAP system, IDocs are stored in database tables.
- IDocs are independent of the sending and receiving systems.
- IDocs are independent of the direction of data exchange.
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: WE 30
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 à Click on Execute Button
Go for New Entries
1) System Name : LOG1:Description: Sending System
2) System Name : LOG2:Description: 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:
Select Assign Client to Logical Systems -
Client : Sending System
Logical System : LOG1
and also
Client : Receiving System
Logical System : LOG2
Save this Data.
Step 2) For RFC Creation:
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
System No : 00
Client : 210
User : Login user name
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 : LMOD
Sender : LOG1
Receiver : LOG2
Message type: ZAZHARMESS
Save and press Enter.
4) Goto Tcode BD82:
Give Model View : LMOD
Partner system : LOG2
Execute this by pressing F8
It will gives you sending system port No: A00000000089 (Like)
5) Goto Tcode BD64:
Select the model view
Goto >Edit >model view > Distribute
Press ok & Press Enter.
Run your Zprogram
REPORT ZIDOC1 .
DATA: Begin of imara occurs 0,
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.
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
> Creating IDoc
> Defining the Segment
> Creating Message Type
> Assigning the Message Type
> Defining the Logical System
> Assigning the Logical System
> Creating the Distribution Model
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 >Application Document posted
----------------------实例------------------------------------------------Outbound Idoc-
ls_poitem TYPE ypoitem,
ls_edidc TYPE edidc,
lt_edidc TYPE TABLE OF edidc,
lt_edidd TYPE TABLE OF edidd WITH HEADER LINE.
ls_edidc-mestyp = 'YPO'. "Message Type
ls_edidc-idoctp = 'YPOIDOC'. "IDOC Type
ls_edidc-rcvprt = 'LS'. "Partner Type of Receiver
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.
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.
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'.
ls_poitem-meins = 'M'.
lt_edidd-sdata = ls_poitem.
APPEND lt_edidd.
EXPORTING
master_idoc_control = ls_edidc "Export
TABLES
communication_idoc_control = lt_edidc "Import
master_idoc_data = lt_edidd "Export
EXCEPTIONS
error_in_idoc_control = 1
error_writing_idoc_status = 2
error_in_idoc_data = 3
sending_logical_system_unknown = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
COMMIT WORK.
WRITE: 'Idoc sent:'.
LOOP AT lt_edidc INTO ls_edidc.
NEW-LINE.
WRITE: 'Idoc number is', ls_edidc-docnum,
'; receiver partner is', ls_edidc-rcvprn,
'; sender partner',ls_edidc-sndprn.
ENDLOOP.
ENDIF.
---------------------------------------实例----------------------------------Inbound Idoc
ls_chead TYPE ypohead,
ls_citem TYPE ypoitem,
ls_pohead TYPE y02_pohead,
lt_poitem TYPE TABLE OF y02_poitem WITH HEADER LINE.
READ TABLE idoc_contrl INDEX 1.
IF idoc_contrl-mestyp <> 'YPO'.
RAISE wrong_function_called.
ENDIF.
CLEAR: ls_pohead, lt_poitem[].
LOOP AT idoc_data WHERE docnum = idoc_contrl-docnum.
CASE idoc_data-segnam.
WHEN 'YPOHEAD'.
CLEAR: ls_chead, ls_pohead.
ls_chead = idoc_data-sdata.
MOVE-CORRESPONDING ls_chead TO ls_pohead.
WHEN 'YPOITEM'.
CLEAR: ls_citem, lt_poitem.
ls_citem = idoc_data-sdata.
MOVE-CORRESPONDING ls_citem TO lt_poitem.
APPEND lt_poitem.
WHEN OTHERS.
ENDCASE.
ENDLOOP.
INSERT y02_pohead FROM ls_pohead.
IF sy-subrc = 0.
INSERT y02_poitem FROM TABLE lt_poitem.
lv_subrc = sy-subrc.
ELSE. "订单号已经存在
lv_subrc = sy-subrc.
ENDIF.
COMMIT WORK.
CLEAR idoc_status.
idoc_status-docnum = idoc_contrl-docnum.
idoc_status-status = '53'. "IDOC处理成功
APPEND idoc_status.
ELSE.
ROLLBACK WORK.
CLEAR idoc_status.
idoc_status-docnum = idoc_contrl-docnum.
idoc_status-status = '51'. "IDOC不成功
idoc_status-msgty = 'E'. "错误信息
idoc_status-msgid = 'YMSG'.
idoc_status-msgno = '001'.
APPEND idoc_status.
ENDIF.
ENDLOOP.
IDOC创建、发送、接收及程序代码[转]的更多相关文章
- 兼容ie7到ie11,edge,chrome,firefox的ajax发送接收post数据代码
/* * 生成XMLHttpRequest */ function getxhr() { //获取ajax对象 var xhr = null; try { xhr = new XDomainReque ...
- Android Java使用JavaMail API发送和接收邮件的代码示例
JavaMail是Oracle甲骨文开发的Java邮件类API,支持多种邮件协议,这里我们就来看一下Java使用JavaMail API发送和接收邮件的代码示例 使用Javamail发送邮件,必需的j ...
- 管道通信实例(A程序作为服务器,不断从B程序接收数据,并发送到C程序中)
A程序作为服务器,不断从B程序接收数据,并发送到C程序中:#include <stdio.h>#include <conio.h> #include <tchar.h&g ...
- 创建C#串口通信程序详解
在.NET平台下创建C#串口通信程序,.NET 2.0提供了串口通信的功能,其命名空间是System.IO.Ports.这个新的框架不但可以访问计算机上的串口,还可以和串口设备进行通信.我们将使用标准 ...
- 微信小程序客服消息开发实战:实时在手机上接收小程序客服消息通知,以及在手机上回复
在微信小程序开发中,可以非常方便的集成客服功能,只需要一行代码便可以将用户引导至客服会话界面.这行代码就是: <button open-type="contact" bind ...
- C# 模拟串口发送接收
一.准备虚拟串口驱动工具 创建俩个虚拟串口,如图: 二.创建两个控制台程序 模拟串口的发送接收数据 1. 接收数据,代码如下: //遍历串行端口名称数组 foreach (string port in ...
- MFC Wizard创建的空应用程序中各个文件内容的解析
创建的MFC应用程序名为:wd,那么: 一.wd.h解析 // wd.h : main header file for the WD application // #if !defined(AFX_W ...
- [NIO]用dawn发送接收HTTP请求
HTTP协议的下层使用的是tcp.所以我们建立一个tcp连接就能发送接收http请求.dawn底层使用了nio.可是经过dawn的封装之后,我们在编写代码的时候,就和使用普通的堵塞式socket一样 ...
- 创建安全的 Netty 程序
1.使用 SSL/TLS 创建安全的 Netty 程序 SSL 和 TLS 是众所周知的标准和分层的协议,它们可以确保数据时私有的 Netty提供了SSLHandler对网络数据进行加密 使用Http ...
随机推荐
- Beaglebone Black– 智能家居控制系统 LAS - 刷 WiFi 模块 ESP8266 Firmware 和 ESP8266 直接收发 GPIO 信号
用 Windows 来刷 ESP8266 固件有很多中文教程,来试试直接用 BBB 刷吧.目标是 NodeMCU,ESP-01 可用,就是我买的那个. 接线方式在上一篇.当 echo ‘BB-UART ...
- ARM寻址方式
寻址方式: 所谓寻址方式就是处理器根据指令中给出的信息来找到指令所需操作数的方式. 1.立即数寻址 2.寄存器寻址 3.寄存器间接寻址 就是寄存器中存放的是操作数在内存中的地址 例如以下指令: LDR ...
- hdu 1348 (凸包求周长)
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1348 Wall Time Limit: 2000/1000 MS (Java/Others) Mem ...
- Berkeley 四种产品如何选择?
Berkeley 四种产品如何选择? 四种产品综览 Berkeley 可供选择的四款产品: DS: 简单的.支持单写单读的数据存储:支持高并发,多进程同时读操作:不支持锁,这就意味着当程序在进行更新和 ...
- monkeyrunner自动登录脚本
自己写了个平时测试的app的自动登录脚本,亲测可运行.读者参照时只需要改包名.activity名称.坐标值.账号和密码即可 查看坐标是多少的方法:使用手机的指针位置来实现:系统设置---开发者选项-- ...
- iBATIS sql(XML)中的大于、小于、like等符号写法
其实就是xml的特殊符号,因为它的配置就是xml,所以可以用下面这种写法转义 < < > > <> < ...
- JSP学习——语法
JSP模版元素 JSP表达式 JSP脚本片断 JSP注释JSP指令JSP标签 JSP内置对象如何查找JSP页面中的错误 1:JSP模版元素 : JSP页面中的HTML内容称之为JSP模版元素. JSP ...
- read 计时命令
使用read命令存在潜在危险,脚本很可能会停下来一直等待脚本用户输入数据,如果无论是否输入数据脚本的必须继续执行,那么可以使用-t选项指定一个计时器.-t选项指定read命令等待输入的秒数,当计数器计 ...
- iOS - Plist 数据解析
前言 NS_AVAILABLE(10_6, 4_0) @interface NSPropertyListSerialization : NSObject 如果对象是 NSArray 或 NSDicti ...
- JS trim()方法使用
JS trim()方法使用上有浏览器限制: 1.直接使用 string.trim() 浏览器版本限制:JavaScript Version 1.8 2.间接使用<即自己使用正则构造类trim的 ...