有个需求,外围系统希望我们给到一个IDOC 记录的样例,但是我们we02中并无法看到
就找了一个demo去直接展示IDOC内容
*&---------------------------------------------------------------------*
*& Report Z_IDOC_TO_XML
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT z_idoc_to_xml.*Global tables
DATA: gt_dyfields LIKE dynpread OCCURS 0 WITH HEADER LINE, "screen fieldsgt_data_tab TYPE TABLE OF string WITH HEADER LINE. "download data tab*Global variables
DATA: gv_filename TYPE string VALUE 'idoc', "file namegv_path TYPE string, "file pathgv_result TYPE i,gv_xml_str TYPE string. "XML stringDATA: idoc TYPE REF TO cl_idoc_xml1. "iDoc class instance*Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE TEXT-002.
PARAMETERS: p_docnum LIKE edidc-docnum OBLIGATORY. "iDoc number
SELECTION-SCREEN END OF BLOCK b2.START-OF-SELECTION.
* Create Object and create IDOC_XMLCREATE OBJECT idocEXPORTINGdocnum = p_docnumEXCEPTIONSerror_loading_idoc = 1error_building_xml = 2OTHERS = 3.IF sy-subrc <> 0.MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgnoWITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4RAISING no_idoc_xml_loaded.ENDIF.* TransformationCALL METHOD idoc->get_xmldata_as_stringIMPORTINGdata_string = gv_xml_str.*append xml string to data tabAPPEND gv_xml_str TO gt_data_tab.CALL METHOD cl_abap_browser=>show_xmlEXPORTINGxml_string = gv_xml_str.
效果如下