Show TOC

Procedure documentationDefining Inbound Processing as an Object Method Locate this document in the navigation structure

Prerequisites

You must have completed the required steps in Defining and Using a Basic Type.

Procedure

  1. Choose   SAP Menu   Tools   IDoc Interface/ALE   Development   IDoc   Inbound Processing   Business Workflow Development   Business Object Builder (SWO1)  . Enter your object type and choose Change (Change).

  2. Define a new method for your object type. Position the cursor on Methods and choose Create (Create).

  3. If you have written a function module as the technical implementation of your method, enter the function module as the template. Enter a name for your method and save your entries.

    In the case of synchronous methods, you do not have to define an event which is used by the method for confirmations.

  4. Position the cursor on the new method and select Program.

  5. Program the processing.

  6. Save the program code and exit the ABAP Editor ().

  7. In the Business Object Builder, change the release status of the method to Implemented. Position the cursor on Methods and choose Edit ? Change release status ? Object Type Component? in implemented.

  8. Choose .

Result

Result

You have implemented a method using a specified ABAP program. You must now create a task which refers to this method and to the corresponding object type.

Example Example

In the example, you should define the synchronous, dialog-free method InputBackgroundTest for your object type IDOCTEST. The source text is as follows:

End of the example.

Syntax Syntax

  1. INCLUDE <OBJECT>.  " Workflow-Makros zur Objektdefinition
    begin_data object. " Do not change.. DATA is generated
    * only private members may be inserted into structure private
    data:
    " begin of private,
    "   to declare private attributes remove comments and
    "   insert private attributes here...
    " end of private,
      begin of key,
          idocnumber like edidc-docnum,
      end of key.
    end_data object. " Do not change.. DATA is generated
    ...
    BEGIN_METHOD inputBackgroundTest changing container.
    CALL FUNCTION 'IDOC_INPUT_WF_TESTER'
      EXPORTING idocnumber = object-key-idocnumber
      EXCEPTIONS
        OTHERS = 01.
    END_METHOD.
    
    
End of the code.

The transferred parameter is IDOCNUMBER, which the object type IDOCTEST has inherited as a key field from the supertype IDOCAPPL.

You can create the function module IDOC_INPUT_WF_TESTER using forward navigation (double-click). The function module reads the data from the IDoc and generates an event if an error occurs (by calling the function module SWE_EVENT_CREATE). In FORM routine READ_IDOC_TESTER, you can see how data from an IDoc table is turned into application tables using segment structures.

Caution Caution

In the following source text it is often referred to the analog for direct inbound processing (for example, IDOC_INPUT_TESTER), however only for reasons of space, since you must select either direct or workflow inbound processing.

End of the caution.
Administration Parameters for IDOC_INPUT_WF_TESTER

Application abbreviation

V (Sales and Distribution)

Processing type

Normal, start immediately

Example

Syntax Syntax

  1. FUNCTION IDOC_INPUT_WF_TESTER. 
    *--------------------------------------------------------- 
    *Globale Schnittstelle:  
    * IMPORTING  idocnumber LIKE EDIDC-DOCNUM 
    *--------------------------------------------------------- 
    
    INCLUDE <CNTNO1>.  " Workflow-Makros zur Containerdefinition 
    DATA: 
    i_edids LIKE edi_ds OCCURS 1 WITH HEADER LINE, 
    event_id like swedumevid-evtid, 
    status like edids-status,
    cidocnumber like sweinstcou-objkey, 
    errorcode like sy-subrc.         "Für Test der Ausnahmebehandlung 
    swc_container       ev_container. 
    
    * initialize SET/GET parameters and internal tables 
    PERFORM INITIALIZE_ORGANIZATIONAL_DATA. 
    
    CALL FUNCTION 'EDI_DOCUMENT_OPEN_FOR_PROCESS' 
         EXPORTING 
           document_number = idocnumber 
         IMPORTING 
              idoc_control             = idoc_contrl 
         EXCEPTIONS 
              document_foreign_lock    = 01 
              document_not_exist       = 02 
              document_number_invalid  = 03 
              document_is_already_open = 04.
    
    CALL FUNCTION 'EDI_SEGMENTS_GET_ALL' 
         EXPORTING 
              document_number         = idocnumber 
         TABLES 
              idoc_containers         = idoc_data 
         EXCEPTIONS 
              document_number_invalid = 01 
              end_of_document         = 02. 
    
    PERFORM READ_IDOC_TESTER. 
    
    PERFORM CALL_VA01_IDOC_ORDERS 
                using errorcode. 
    
    PERFORM WRITE_STATUS_RECORD TABLES i_edids   "Status schreiben
       USING errorcode.
    
    CALL FUNCTION 'EDI_DOCUMENT_CLOSE_PROCESS'
         EXPORTING
              document_number     = idocnumber
         IMPORTING
              idoc_control        = idoc_contrl
         EXCEPTIONS
              document_not_open   = 01
              failure_in_db_write = 02
              parameter_error     = 03
              status_set_missing  = 04.
    IF errorcode <> 0.
      cidocnumber = idocnumber.
      CALL FUNCTION 'SWE_EVENT_CREATE'
           EXPORTING
                objtype              = 'IDOCTEST'
                objkey               = cidocnumber
                event                = 'InputErrorOccurred'
                start_recfb_synchron = 'X'       "synchroner Aufruf
           IMPORTING
                event_id             = event_id
           TABLES
                event_container      = ev_container
           EXCEPTIONS
                objtype_not_found    = 1
                others               = 2.
      COMMIT WORK.
    ENDIF.
    ENDFUNCTION.
    
    FORM INITIALIZE_ORGANIZATIONAL_DATA
    ...
    * Formroutine wie im Abschnitt 
    * Funktionsbaustein anlegen (direkter Eingang)
    
    ENDFORM.                     " INITIALIZE_ORGANIZATIONAL_DATA
    
    FORM READ_IDOC_TESTER.
    ...
    * Formroutine und aufgerufene Routinen wie im Abschnitt 
    * Funktionsbaustein anlegen (direkter Eingang)
    
    ENDFORM.                     " READ_IDOC_TESTER
    
    
    FORM CALL_VA01_IDOC_ORDERS using errorcode.
    
    * call transaction first dynpro
      PERFORM DYNPRO_START.
    * call transaction double-line entry
      PERFORM DYNPRO_DETAIL2.
    * incoterms
      PERFORM DYNPRO_HEAD_300.
    * call transaction item datas
      PERFORM DYNPRO_POSITION.
      PERFORM DYNPRO_SET USING 'BDC_OKCODE' 'SICH'.
    * call transaction VA01
     CALL TRANSACTION 'VA01' USING    BDCDATA
                             MODE     'N'
                             UPDATE   'S'
                             MESSAGES INTO XBDCMSGCOLL.
    
    errorcode = SY-SUBRC.       " remember returncode for status update
    
    ENDFORM.                    " CALL_VA01_IDOC_ORDERS
    
    FORM DYNPRO_START.
    ...
    * Formroutine und aufgerufene Routinen wie im Abschnitt 
    * Funktionsbaustein anlegen (direkter Eingang)
    
    ENDFORM.                     " DYNPRO_START
    
    
    FORM WRITE_STATUS_RECORD TABLES i_edids STRUCTURE edi_ds
    USING errorcode.
    
    * fill status record
     I_EDIDS-DOCNUM = IDOC_CONTRL-DOCNUM.
     I_EDIDS-LOGDAT = SY-DATUM.
     IF errorcode = 0.
       I_EDIDS-STATUS = BELEG_GEBUCHT.                 "value 53
       GET PARAMETER ID 'AUN' FIELD BELEGNUMMER.
       I_EDIDS-STAMID = 'V1'.
       I_EDIDS-STAMNO = '311'.
       I_EDIDS-STAPA1 = 'Terminauftrag'.
       I_EDIDS-STAPA2 = BELEGNUMMER.
     ELSE.
    I_EDIDS-STATUS = BELEG_NICHT_GEBUCHT.               "value 51
        I_EDIDS-STAMID = SY-MSGID.
        I_EDIDS-STAMNO = SY-MSGNO.
        I_EDIDS-STAPA1 = SY-MSGV1.
        I_EDIDS-STAPA2 = SY-MSGV2.
        I_EDIDS-STAPA3 = SY-MSGV3.
        I_EDIDS-STAPA4 = SY-MSGV4.
      ENDIF.
    
    CALL FUNCTION 'EDI_DOCUMENT_STATUS_SET'
    EXPORTING
              document_number         = idoc_contrl-docnum
              idoc_status             = i_edids
         IMPORTING
              idoc_control            = idoc_contrl
         EXCEPTIONS
              document_number_invalid = 01
              other_fields_invalid    = 02
              status_invalid          = 03.
    ENDFORM.                               " WRITE_STATUS_RECORD
    
    Globale Daten von IDOC_INPUT_WF_TESTER
    data:
    idoc_data LIKE edidd occurs 10 WITH HEADER LINE,
    idoc_contrl LIKE edidc occurs 1 WITH HEADER LINE.
    * weitere Daten wie im Abschnitt 
    * Funktionsbaustein anlegen (direkter Eingang)
    
End of the code.