Step by Step for configuration of sending customize IDOC/自定义IDOC发送配置
Step by Step for configuration of sending customize IDOC
- WE31 创建IDOC所包含的字段
- WE30 创建IDOC 把Segment分配给IDOC
- WE81 创建信息类型
- WE82 把IDOC类型与信息类型对应
- WE57 Assign Message & Idoc Type to a Function Module for data Process (Optional)
- 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
First create Logical system in SALE
- Use program to build and send out IDOC
REPORT ZTESTFORGG_SENDIDOC.
DATA: head TYPE zgghead,
item TYPE zggitem,
char TYPE zggchar.
DATA: control_data LIKE edidc,
data LIKE edidd OCCURS 0 WITH HEADER LINE,
communication LIKE edidc OCCURS 0 WITH HEADER LINE.
* Master idoc control record
control_data-rcvprt = 'LS'.
control_data-rcvprn = 'ZGG_OUT_LS'.
control_data-rcvpor = 'ZGG_OUT'.
control_data-idoctp = 'ZGGIDOC'.
control_data-mestyp = 'ZGGMSG'.
* master idoc data records
head-f1 = 'Header'.
data-segnam = 'ZGGHEAD'.
data-sdata = head.
append data.
item-if1 = 'Item1'.
data-segnam = 'ZGGITEM'.
data-sdata = item.
APPEND data.
char-cf1 = 'Char1'.
data-segnam = 'ZGGCHAR'.
data-sdata = char.
APPEND data.
item-if1 = 'Item2'.
data-segnam = 'ZGGITEM'.
data-sdata = item.
APPEND data.
char-cf1 = 'Char21'.
data-segnam = 'ZGGCHAR'.
data-sdata = char.
APPEND data.
char-cf1 = 'Char22'.
data-segnam = 'ZGGCHAR'.
data-sdata = char.
APPEND data.
item-if1 = 'Item3'.
data-segnam = 'ZGGITEM'.
data-sdata = item.
APPEND data.
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
master_idoc_control = control_data
TABLES
communication_idoc_control = communication
master_idoc_data = data.
IF sy-subrc = 0.
COMMIT WORK.
ENDIF.
- WE02 to Check result
- Use program RSEOUT00 (usually set up as job) to send to external system
Part II: Configuration for inbound IDOC
- BD64 to create distribution model (Optional)
- BD51 to maintain the characteristic of Inbound processing function module
First create a FM with fix parameters (creation with referring to FM IDOC_INPUT_MATMAS01)
- WE57 to mapping the Inbound processing function module with message type
- WE42 to Create inbound process code
- WE20 to add the inbound message into logical system
手工处理inbound IDOC:BD87, 程序:RBDAPP01(BD20,可用于schedule一个job)RBDMANI2
Test inbound processing
Create a table to store the inbound IDOC data
BD87 to process inbound IDOC
Recipient中的Port要维护成WE20里面Message对应的LS
Check the data in table
Inbound processing function module:
FUNCTION zggmsg_in_proc.
*"----------------------------------------------------------------------
*"*"Global Interface:
*" IMPORTING
*" VALUE(INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD
*" VALUE(MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC
*" VALUE(NO_APPLICATION_LOG) LIKE SY-DATAR OPTIONAL
*" VALUE(MASSSAVEINFOS) LIKE MASSSAVINF STRUCTURE MASSSAVINF
*" OPTIONAL
*" EXPORTING
*" VALUE(WORKFLOW_RESULT) LIKE BDWF_PARAM-RESULT
*" VALUE(APPLICATION_VARIABLE) LIKE BDWF_PARAM-APPL_VAR
*" VALUE(IN_UPDATE_TASK) LIKE BDWFAP_PAR-UPDATETASK
*" VALUE(CALL_TRANSACTION_DONE) LIKE BDWFAP_PAR-CALLTRANS
*" TABLES
*" IDOC_CONTRL STRUCTURE EDIDC
*" IDOC_DATA STRUCTURE EDIDD
*" IDOC_STATUS STRUCTURE BDIDOCSTAT
*" RETURN_VARIABLES STRUCTURE BDWFRETVAR
*" SERIALIZATION_INFO STRUCTURE BDI_SER
*" EXCEPTIONS
*" WRONG_FUNCTION_CALLED
*"----------------------------------------------------------------------
DATA: wa_idoc_control TYPE edidc,
wa_idoc_data TYPE edidd,
gv_time TYPE sy-uzeit,
gv_index TYPE i,
gv_appt_ser TYPE string.
DATA: lt_zggmsg TYPE STANDARD TABLE OF zggmsg,
lw_zggmsg TYPE zggmsg,
lv_key1 TYPE timestampl,
lv_key TYPE timestamp.
IF idoc_contrl-mestyp = 'ZGGMSG'.
"check if it is the right message type
****for inbound IDoc receive, you can't delete this block of code, otherwise the inbound IDoc will be error
READ TABLE idoc_contrl INDEX 1.
"/h
IF sy-subrc = 0.
idoc_status-docnum = idoc_contrl-docnum.
idoc_status-status = '53'.
idoc_status-msgty = 'S'.
idoc_status-msgid = '00'.
idoc_status-msgno = '001'.
idoc_status-msgv1 = 'This is '.
idoc_status-msgv2 = 'a message '.
idoc_status-msgv3 = 'from '.
idoc_status-msgv4 = 'Gavin'.
ELSE.
idoc_status-docnum = idoc_contrl-docnum."/h
idoc_status-status = '51'.
ENDIF.
APPEND idoc_status.
****for inbound IDoc receive, you can't delete this block of code, otherwise the inbound IDoc will be error
CLEAR gv_index.
LOOP AT idoc_data WHERE segnam = 'ZGGCHAR'.
gv_index = gv_index + 1.
GET TIME STAMP FIELD lv_key.
GET TIME STAMP FIELD lv_key1.
lw_zggmsg-cdate = lv_key.
lw_zggmsg-seqnum = gv_index.
lw_zggmsg-cf1 = idoc_data-sdata.
READ TABLE idoc_data WITH KEY segnum = idoc_data-psgnum.
IF sy-subrc = 0.
lw_zggmsg-if1 = idoc_data-sdata.
READ TABLE idoc_data WITH KEY segnum = idoc_data-psgnum.
IF sy-subrc = 0.
lw_zggmsg-f1 = idoc_data-sdata.
ENDIF.
ENDIF.
APPEND lw_zggmsg TO lt_zggmsg.
CLEAR lw_zggmsg.
ENDLOOP.
ENDIF.
IF lt_zggmsg IS NOT INITIAL.
MODIFY zggmsg FROM TABLE lt_zggmsg.
COMMIT WORK AND WAIT.
ENDIF.
ENDFUNCTION.
Some related link:
http://docs.oracle.com/cd/B14099_19/integrate.1012/b14061/processing.htm
http://blog.csdn.net/hackai886/article/details/7930052
Some more testing:
If change the RFC connection to another client
Send IDOC out from 781, and firstly in 782 it will get error:
Add parameters in WE20 (first need to maintain WE42)
BD87 reprocess the IDOC
Check in table