有个需求,外围系统希望我们给到一个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 fields
gt_data_tab TYPE TABLE OF string WITH HEADER LINE. "download data tab
*Global variables
DATA: gv_filename TYPE string VALUE 'idoc', "file name
gv_path TYPE string, "file path
gv_result TYPE i,
gv_xml_str TYPE string. "XML string
DATA: 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_XML
CREATE OBJECT idoc
EXPORTING
docnum = p_docnum
EXCEPTIONS
error_loading_idoc = 1
error_building_xml = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
RAISING no_idoc_xml_loaded.
ENDIF.
* Transformation
CALL METHOD idoc->get_xmldata_as_string
IMPORTING
data_string = gv_xml_str.
*append xml string to data tab
APPEND gv_xml_str TO gt_data_tab.
CALL METHOD cl_abap_browser=>show_xml
EXPORTING
xml_string = gv_xml_str.
效果如下