Inbound IDOC Development

 

 

Develop posting program

The posting program is implemented as a function module that handles posting of the inbound idoc (For eaxmple by suing batch input). Naming convetion: ZIDOC_INPUT_<message type>

Posting programs have a standard interface for there input, output and table parameters (See example below).

Note that IDoc status codes can be found in transaction WE47.

Example of posting program:

FUNCTION zidoc_input_zprocord .
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     VALUE(INPUT_METHOD) LIKE  BDWFAP_PAR-INPUTMETHD
*"     VALUE(MASS_PROCESSING) LIKE  BDWFAP_PAR-MASS_PROC
*"  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
*"      OTHERS
*"----------------------------------------------------------------------


  DATA:
     it_edidd   TYPE STANDARD TABLE OF edidd,
     wa_z1procord LIKE z1procord,
     l_return TYPE string,
*    lt_return TYPE STANDARD TABLE OF string,
     l_subrc LIKE sy-subrc,
     l_posting_error(1) TYPE c,
     l_posting_ok(1) TYPE c.


  in_update_task = ''.

* Check if the function module is called correctly                     *
  READ TABLE idoc_contrl INDEX 1.
  IF sy-subrc <> 0.
    EXIT.
  ELSEIF idoc_contrl-mestyp <> 'ZPROCORD'.
    RAISE wrong_function_called.
  ENDIF.

*----------------------------------------------------------------------
* Loop through all Idocs
*----------------------------------------------------------------------
  LOOP AT idoc_contrl.

*----------------------------------------------------------------------
* Select segments belonging to the Idoc
*----------------------------------------------------------------------
    REFRESH: it_edidd.
    LOOP AT idoc_data WHERE docnum = idoc_contrl-docnum.
      APPEND idoc_data TO it_edidd.
    ENDLOOP.

*----------------------------------------------------------------------
* Loop through the segments
*----------------------------------------------------------------------
    REFRESH idoc_status.
    CLEAR:
       l_posting_error,
       l_posting_ok.



    LOOP AT it_edidd INTO idoc_data.
      CASE idoc_data-segnam.
        WHEN 'Z1PROCORD'.
          CLEAR wa_z1procord.
          wa_z1procord = idoc_data-sdata.

          CLEAR l_subrc.
          PERFORM call_transaction
            USING    wa_z1procord
            CHANGING l_subrc
                     l_return.

          IF l_subrc = 0.
            l_posting_ok = 'X'.

          ELSE.
            l_posting_error = 'X'.
*            APPEND l_return TO lt_return.
          ENDIF.
      ENDCASE.
    ENDLOOP.

*----------------------------------------------------------------------
* Set Idoc status code
*----------------------------------------------------------------------
    CLEAR idoc_status.
    idoc_status-docnum = idoc_contrl-docnum.
    IF l_posting_ok = 'X' AND l_posting_error IS INITIAL.
*      Application document posted
      idoc_status-status = '53'.
    ELSEIF l_posting_error = 'X' AND l_posting_ok IS INITIAL.
*     Error: Application document not posted
      idoc_status-status = '51'.
      idoc_status-msgty  = 'E'.
      idoc_status-msgid  = 'ZPP_SIMATIC_INTERFAC'.
      idoc_status-msgno  = '11'.
*     idoc_status-msgv1 = l_return.


    ELSEIF l_posting_ok = 'X' AND l_posting_error = 'X'.
*     Application document not fully posted
      idoc_status-status = '52'.
      idoc_status-msgty  = 'E'.
      idoc_status-msgid  = 'ZPP_SIMATIC_INTERFAC'.
      idoc_status-msgno  = '10'.
*      idoc_status-msgv1 = l_return.

    ENDIF.
    APPEND idoc_status.

  ENDLOOP.


ENDFUNCTION.

 

 

 

 

 

 

 

Converted from CHM to HTML with chm2web Standard 2.7 (unicode)