[ABAP] IDoc: Segmente und Statusinfos lesen

* http://thinkdoforward.com/sap-idoc-tabellen-erfahrene-berater-kennen-diese-tabellen/

* Tabellen: EDIDC   – Kontrollsatz (IDoc)
*           EDIDS   – Statussatz (IDoc)
*           EDID4   – IDoc-Datensätze ab 4.0
*           EDISDEF - IDoc Entwicklung : IDoc Segmentdefinitionen
*           EDSAPPL - EDI: IDoc-Segment Anwendungsstruktur
*           EDIMSGT - Kurzbeschreibung der SAP Nachrichtentypen

* IDoc-Nummer
PARAMETERS: p_idoc TYPE edidc-docnum DEFAULT '12345'.

START-OF-SELECTION.

  DATA: lv_idoc_control TYPE edidc.
  DATA: lv_number_of_data_records TYPE sy-dbcnt.
  DATA: lv_number_of_status_records TYPE sy-dbcnt.
  DATA: it_int_edids TYPE STANDARD TABLE OF edids WITH DEFAULT KEY.
  DATA: it_int_edidd TYPE STANDARD TABLE OF edidd WITH DEFAULT KEY.

* Lesen aller Informationen eines IDocs
  CALL FUNCTION 'IDOC_READ_COMPLETELY'
    EXPORTING
      document_number          = p_idoc
    IMPORTING
      idoc_control             = lv_idoc_control
      number_of_data_records   = lv_number_of_data_records
      number_of_status_records = lv_number_of_status_records
    TABLES
      int_edids                = it_int_edids
      int_edidd                = it_int_edidd
    EXCEPTIONS
      document_not_exist       = 1
      document_number_invalid  = 2
      OTHERS                   = 3.

  IF sy-subrc = 0.
    cl_demo_output=>write_data( lv_idoc_control ).
    cl_demo_output=>write_data( lv_number_of_data_records ).
    cl_demo_output=>write_data( lv_number_of_status_records ).
    cl_demo_output=>write_data( it_int_edids ).
    cl_demo_output=>write_data( it_int_edidd ).
    cl_demo_output=>display( ).
  ENDIF.