首页 > 代码库 > Step by Step for configuration of sending customize IDOC/自定义IDOC发送配置

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

<div style="width: 600px; max-width: 100%; margin-bottom:5px;"><a href="https://docs.com/gan-gavin/6042/idoc-step-by-step-for-configuration-of-sending" title="自定义IDOC配置/Step by Step for configuration of sending customize IDOC" target="_blank" style="font-family: ‘Segoe UI‘; font-size: 13px; text-decoration: none; margin-left:18px ">自定义IDOC配置/Step by Step for configuration of sending customize IDOC</a><span style="font-family: ‘Segoe UI‘; font-size: 13px ">—</span><a href="https://docs.com/gan-gavin" target="_blank" style="font-family: ‘Segoe UI‘; font-size: 13px; text-decoration: none ">Gan Gavin</a><a style="float: right; margin-bottom:5px; margin-right:18px; font-family: ‘Segoe UI‘; font-size: 13px; text-decoration: none " href="https://docs.com/gan-gavin/6042/idoc-step-by-step-for-configuration-of-sending" target="_blank">Docs.com</a></div><iframe src="https://docs.com/d/embed/D25191387-4972-2481-4090-000002467748%7eMed2b92be-eecb-8771-95eb-bbcc19ea8b58" frameborder="0" scrolling="no" width="600px" height="812px" style="max-width:100%" allowfullscreen="False"></iframe>

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

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.

  1. WE02 to Check result

 

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

 

Part II: Configuration for inbound IDOC

  1. BD64 to create distribution model (Optional)

 

  1. BD51 to maintain the characteristic of Inboundprocessing function module

First create a FM with fixparameters (creation with referring to FM IDOC_INPUT_MATMAS01)

 

 

  1. WE57 to mapping the Inbound processing functionmodule with message type

 

  1. WE42 to Create inbound process code

 

  1. WE20 to add the inbound message into logicalsystem

 

手工处理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 geterror:

 

Add parameters in WE20 (first need to maintain WE42)

 

 

BD87 reprocess the IDOC

 

Check in table

 

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