How to copy IDoc from one system to another

The functionality that copying IDoc from production to testing system is very useful in EDI support work. From technical point, how can we copy/sync IDoc(s) cross system?

 

So far as I know, they are two ways:
1. Write IDoc data into a file -> upload IDoc file to target system manually or by UNIX script -> use WE19 load the file as a template to generate new IDoc.

 

2. Call function module remotely or in Proxy subroutine (Prefer)
    a) INBOUND_IDOC_PROCESS or IDOC_INBOUND_ASYNCHRONOUS
    b) IDOC_CREATE_ON_DATABASE or
    c) IDOC_INBOUND_SINGLE

    d) MASTER_IDOC_DISTRIBUTE  (for copying outbound idoc)

* Process any 3.1 IDocs received.  

CALL FUNCTION 'INBOUND_IDOC_PROCESS'
     TABLES
         IDOC_CONTROL = IDOC_CONTROL
         IDOC_DATA         = IDOC_DATA.

 * Process any 4.1 IDocs received.

CALL FUNCTION 'IDOC_INBOUND_ASYNCHRONOUS'
      TABLES
          IDOC_CONTROL_REC_40 = IDOC_CONTROL40
          IDOC_DATA_REC_40    = IDOC_DATA40.

 CALL FUNCTION 'IDOC_CREATE_ON_DATABASE'
    EXPORTING
        IDOC_STATUS             = WA_EDIDS
        ERROR_OCCURED    = LV_ERROR_OCCURED
    TABLES
        IDOC_DATA                  = IT_EDIDD
    CHANGING
        IDOC_CONTROL           = WA_EDIDC
    EXCEPTIONS
        IDOC_INPUT_INCONSISTENT = 1
        OTHERS                                       = 2.

 CALL FUNCTION 'IDOC_INBOUND_SINGLE' STARTING NEW TASK 'ERR'
    EXPORTING
        pi_idoc_control_rec_40  = w_edidc
*      pi_do_commit                 = 'X'
    TABLES
       pt_idoc_data_records_40 = w_edidd
    EXCEPTIONS
       idoc_not_saved          = 1
    OTHERS                       = 2.

 

NOTE: Before writing IDoc to file or calling FM, we need do some changes to IDoc control data
1. Clear EDIDC-MANDT
2. Clear IDoc number
3. Change the version of segments, EDIDC-SEGNAM(2), like E1 -> E2
4. Authorization check (generally, copy IDoc from testing/dev system to production is not allowed)

你可能感兴趣的:(C++,c,unix,C#)