IDoc handlers and create, update, and delete verbs

IDoc handlers that support Create, Update and Delete operations receive business object data formatted as an IDoc. The role of these operations is to integrate the business object data with SAP's Call Transaction API and generate an object key. Only the object key is passed back to Y_XR_IDOC_HANDLER, not the business object data. Y_XR_IDOC_HANDLER stores the business object data in memory and inserts the object key into the first attribute marked isKey in the parent business object. Then, Y_XR_IDOC_HANDLER passes the business object data back to the connector.

Note:
When InterChange Server (ICS) is the integration broker, it is critical to maintain the business object data because the mapping infrastructure requires the preservation of the ObjectEventId for dynamic cross-referencing.

The sample code below represents the following flow:

  1. Initializes global data.
  2. Deconstructs the IDoc into working tables.
  3. Builds the BDC. Uses the forms in YXRIFRM0 to transfer data from the internal tables into the BDC table for consistent behavior across objects.
  4. Creates a Call Transaction.
  5. Captures the object key.

The following sample code supports SAP Sales Quote Create:

*- Initialize working variables and internal tables
   PERFORM INITIALIZE_IN.
  
 *- I01(MF): Begin IDoc interpretation
   PERFORM LOG_UPDATE(SAPLYXR1) USING C_INFORMATION_LOG TEXT-I01
                                      SPACE SPACE SPACE.
  
 *- Interpret IDoc data structure
   IF NOT IDOC_DATA[] IS INITIAL.
  
 *- Move IDoc to internal tables
     PERFORM INTERPRET_IDOC.
  
 *- Check some of the input fields
     PERFORM CHECK_INPUT.
  
 *- If key values were missing, exit function
     IF RETURN_CODE NE 0.
       EXIT.
     ENDIF.
  
 *- E01(MF): No Idoc data lines sent for processing.
   ELSE.
  
     RETURN_CODE = 2.
     RETURN_TEXT = TEXT-E01.
     EXIT.
  
   ENDIF.
  
 *- Build the BDC session for transaction VA21.
   PERFORM BUILD_BDC_VA21.
  
 *- Call Transaction
   PERFORM LOG_UPDATE(SAPLYXR1) USING C_INFORMATION_LOG TEXT-I02
                                      'VA21' C_BLANK C_BLANK.
  
   CALL TRANSACTION 'VA21' USING BDCDATA
                            MODE INPUT_METHOD
                          UPDATE 'S'
                        MESSAGES INTO BDC_MESSAGES.
  
 *- Capture return code and object key from transaction
   PERFORM PREPARE_RETURNED_MESSAGE.
  
 ENDFUNCTION.
 

The Create logic has two main functions:

Translating IDOC structure

The first part of the Create logic is the task of translating data in the IDoc structure into working data structures. To do this, you need to create code similar to the following:

loop at idoc_data.
  
     case idoc_data-segnam.
       when 'ZSQVBAK'.                  " Header Data
         move idoc_data-sdata to zsqvbak.
  
       when 'ZSQVBUK'.                  " Status Segment
         move idoc_data-sdata to zsqvbuk.
  
       when 'ZSQVBP0'.                  " Partner Header Level
         move idoc_data-sdata to zsqvbp0.
  
       when 'ZSQVBAP'.                  " Item Detail
         move idoc_data-sdata to zsqvbap.
  
       when 'ZSQVBA2'.                  " Item Detail Part 2
         move idoc_data-sdata to zsqvba2.
  
       when 'ZSQVBUP'.                  " Item Status
         move idoc_data-sdata to zsqvbup.
  
       when 'ZSQVBKD'.                  " Commerical data
         move idoc_data-sdata to zsqvbkd.
  
       when 'ZSQKONV'.                  " Condition
         move idoc_data-sdata to zsqkonv.
  
       when 'ZSQVBPA'.                  " Partner Item Level
         move idoc_data-sdata to zsqvbpa.
  
     endcase.
  
   endloop.
 

Copyright IBM Corp. 1997, 2003