Updating IDoc data in segments

By Kevin Wilson - From ErpGenie.com
STEP 1 - Open document to edit 
CALL FUNCTION 'EDI_DOCUMENT_OPEN_FOR_EDIT' 
       EXPORTING 
            document_number               = t_docnum 
       IMPORTING 
            idoc_control                  = itab_edidc 
       TABLES 
            idoc_data                     = itab_edidd 
       EXCEPTIONS 
            document_foreign_lock         = 1 
            document_not_exist            = 2 
            document_not_open             = 3 
            status_is_unable_for_changing = 4 
            OTHERS                        = 5. 

STEP 2 - Loop at itab_edidd and change data 

LOOP AT itab_edidd WHERE segnam = 'E1EDKA1'. 
  e1edka1 = itab_edidd-sdata. 
  IF e1edka1-parvw = 'LF'. 
    e1edka1-partn = t_eikto.
    itab_edidd-sdata = e1edka1. 
    MODIFY itab_edidd.
    EXIT.
  ENDIF.
ENDLOOP. 
STEP 3 - Change data segments 

CALL FUNCTION 'EDI_CHANGE_DATA_SEGMENTS' 
           TABLES 
                idoc_changed_data_range = itab_edidd 
           EXCEPTIONS 
                idoc_not_open           = 1 
                data_record_not_exist   = 2 
                OTHERS                  = 3.

STEP 3a - Change control record

CALL FUNCTION 'EDI_CHANGE_CONTROL_RECORD' 
       EXPORTING 
            idoc_changed_control         = itab_edidc 
       EXCEPTIONS 
            idoc_not_open                = 1 
            direction_change_not_allowed = 2 
            OTHERS                       = 3. 

STEP 4 - Close Idoc

* Update IDoc status

CLEAR t_itab_edids40. 
  t_itab_edids40-docnum      = t_docnum. 
  t_itab_edids40-status      = '51'. 
  t_itab_edids40-repid       = sy-repid. 
  t_itab_edids40-tabnam      = 'EDI_DS'. 
  t_itab_edids40-mandt       = sy-mandt. 
  t_itab_edids40-stamqu      = 'SAP'. 
  t_itab_edids40-stamid      = 'B1'. 
  t_itab_edids40-stamno      = '999'. 
  t_itab_edids40-stapa1      = 'Sold to changed to '. 
  t_itab_edids40-stapa2      = t_new_kunnr. 
  t_itab_edids40-logdat      = sy-datum. 
  t_itab_edids40-logtim      = sy-uzeit. 
  APPEND t_itab_edids40. 

  

  CALL FUNCTION 'EDI_DOCUMENT_CLOSE_EDIT' 
       EXPORTING 
            document_number  = t_docnum 
            do_commit        = 'X' 
            do_update        = 'X' 
            write_all_status = 'X'
       TABLES 
            status_records   = t_itab_edids40 
       EXCEPTIONS 
            idoc_not_open    = 1 
            db_error         = 2 
            OTHERS           = 3.


 

 

 

 

 

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