Skip to end of metadata
Go to start of metadata

Setting IDOC status via Custom functionality 

The business requirement is to set IDOC to a certain status via a Custom Program.  This was done as a part of IDOC Archival. The IDOC that qualified as per the criteria were selected and there status was modified. The BASIS then took up these IDOCs and carried out IDOC Archiving for these IDOCs. 

The following FM were used to change the status of IDOCs: 

  • EDI_DOCUMENT_OPEN_FOR_PROCESS
  • EDI_STATUS_ADD_BLOCK
  • EDI_DOCUMENT_CLOSE_PROCESS PROCESS

       

 The Above IDOCs need to be called one after the another.

  EDI_DOCUMENT_OPEN_FOR_PROCESS

    The above FM basically acquires and open the IDOC for modification. It takes IDOC number as INPUT and returns Control Record as Output. 
     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.

 EDI_STATUS_ADD_BLOCK

  *After the above call, then we call the FM *EDI_STATUS_ADD_BLOCK.

    It takes the Input of IDOC number into DOCUMENT_NUMBER and IDOC status record into IDOC_STATUS_RECORDS. For example

    we pass TB_EDI_DS to IDOC_STATUS_RECORDS.

         
    TB_EDI_DS -MANDT  = SY-MANDT.

    TB_EDI_DS -DOCNUM = DOCNUM_IV.                         

    *TB_EDI_DS -STATUS = STATUS_IV."*Here you pass the Status to which IDOC has to be modified for example 68. 

    TB_EDI_DS -LOGDAT = SY-DATUM.

    TB_EDI_DS -LOGTIM = SY-UZEIT.

    TB_EDI_DS -STAMQU = 'SAP'.

    TB_EDI_DS -UNAME  = SY-UNAME. 
                          

    Append TB_EDI_DS. 

EDI_DOCUMENT_CLOSE_PROCESS PROCESS

 

After the above mentioned call is successful, then you call the FM EDI_DOCUMENT_CLOSE_PROCESS PROCESS and pass the IDOC Document number to DOCUMENT_NUMBER

and then COMMIT work.

In this way you can modify the status of IDOCs via your own program f

Change the status of an IDOC, An alternative way.

Another alternative is to use the standard SAP program: RC1_IDOC_SET_STATUS.

Run the program RC1_IDOC_SET_STATUS.

    • Give the Idoc numbers for which you want to change the statuses in the selection screen.
    • Give the current and the new status.
    • Uncheck the Test Run check box and press F8.
    • The statuses of the idocs will be changed.