DATA: idoc_control LIKE edidc,
number_of_data_records LIKE sy-dbcnt,
number_of_status_records LIKE sy-dbcnt,
int_edids LIKE edids OCCURS 0 WITH HEADER LINE,
int_edidd LIKE edidd OCCURS 0 WITH HEADER LINE.
TYPE-POOLS : ledid.
DATA: struct_type TYPE ledid_struct_type ,
idoc_struct TYPE ledid_t_idoc_struct,
segments TYPE ledid_t_segment,
segment_struct TYPE ledid_t_segment_struct,
excel_tab(2000) OCCURS 0 WITH HEADER LINE.
PARAMETER: docnum LIKE edidc-docnum OBLIGATORY, ""Idoc Number
sap_rel LIKE sy-saprl DEFAULT sy-saprl OBLIGATORY,
pi_ver LIKE edi_verrec-version DEFAULT '3' OBLIGATORY,
d_excel AS CHECKBOX DEFAULT 'X'. ""Download ?
START-OF-SELECTION.
PERFORM read_idoc.
PERFORM process_idoc.
IF d_excel = 'X'.
PERFORM download_to_excel.
ENDIF.
END-OF-SELECTION.
*&--------------------------------------------------------------------*
*& Form read_idoc
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM read_idoc.
CALL FUNCTION 'IDOC_READ_COMPLETELY'
EXPORTING
document_number = docnum
IMPORTING
idoc_control = idoc_control
number_of_data_records = number_of_data_records
number_of_status_records = number_of_status_records
TABLES
int_edids = int_edids
int_edidd = int_edidd
EXCEPTIONS
document_not_exist = 1
document_number_invalid = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. "" read_idoc
*&--------------------------------------------------------------------*
*& Form process_idoc
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM process_idoc.
PERFORM read_idoc_structure.
PERFORM display_data_records.
ENDFORM.