Step by Step for configuration of sending customize IDOC/自定义IDOC发送配置

Step by Step for configuration of sending customize IDOC

  1. WE31 创建IDOC所包含的字段



  1. WE30 创建IDOC 把Segment分配给IDOC



  1. WE81  创建信息类型


  1. WE82   把IDOC类型与信息类型对应


  1. WE57 Assign Message & Idoc Type to a Function Module for data Process (Optional)


  1. SM59 Define a RFC connection for Idoc transfer


  1. WE21 Define a Port ( Assign a RFC destination which created in SM59 )


  1. WE41/42 Creat Process Code


  1. WE20 Define a Partner Profiles

First create Logical system in SALE


  1. Use program to build and send out IDOC


  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.

      master_idoc_control = control_data
      communication_idoc_control = communication
      master_idoc_data = data.
  IF sy-subrc = 0.

  1. WE02 to Check result


  1. Use program RSEOUT00 (usually set up as job) to send to external system


Part II: Configuration for inbound IDOC

  1. BD64 to create distribution model (Optional)


  1. 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)



  1. WE57 to mapping the Inbound processing function module with message type


  1. WE42 to Create inbound process code


  1. 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






Check the data in table


Inbound processing function module:

FUNCTION zggmsg_in_proc.
*"*"Global Interface:
*"       OPTIONAL
  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.
    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'.
      idoc_status-docnum = idoc_contrl-docnum."/h
      idoc_status-status = '51'.
    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.

      APPEND lw_zggmsg TO lt_zggmsg.
      CLEAR lw_zggmsg.



  IF lt_zggmsg IS NOT INITIAL.
    MODIFY zggmsg FROM TABLE lt_zggmsg.


Some related link:

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


posted on 2017-03-02 11:34  GavinGan  阅读(265)  评论(0编辑  收藏  举报