Program to retrieve XML Data from IDoc

PARAMETERS : p_idoc TYPE edi_docnum.

START-OF-SELECTION.

  DATA(_o_idoc) = NEW cl_idoc_xml1( docnum = CONV #( p_idoc ) ).
  IF _o_idoc IS BOUND.
    CALL METHOD _o_idoc->get_xmldata_as_string
      IMPORTING
        data_string = DATA(_str).

    REPLACE : ALL OCCURRENCES OF '<![CDATA[' IN _str WITH '',
              ALL OCCURRENCES OF ']]>' IN _str WITH ''.
    IF _str IS NOT INITIAL.
      DATA(_o_xml) = NEW cl_xml_document( ).
      CALL METHOD _o_xml->parse_string
        EXPORTING
          stream = _str.
      CALL METHOD _o_xml->display.
    ELSE.
      MESSAGE i208(00) WITH 'No data found' DISPLAY LIKE 'E'.
    ENDIF.
  ENDIF.

Execute above code to get the XML Data from IDoc

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s