FM to convert XML to string ABAP

XML TO STRING ABAP

Get XML values from ABAP

If you need to convert an XML to string and get values and nodes you must to use two function modules.

SCMS_STRING_TO_XSTRING

This function module need to be called first to convert  XML string to a buffer variable.

SMUM_XML_PARSE

This function module its used to get nodes and values from an xml string from abap, to do to its neccesary  execute first SCMS_STRING_TO_XSTRING to get buffer variable and pass to this FM, please see example below.

DATA: gwa_xml_data  TYPE smum_xmltb,
      gt_return     TYPE TABLE OF bapiret2,
      gv_xml_string TYPE xstring.
CLEAR: gt_xml_data.



CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
  EXPORTING
    text   = i_input-mt_ventas_emision_res-factura-ruta_xml "<-XML STRING
  IMPORTING
    buffer = gv_xml_string    "<-- Here we get buffer variable
  EXCEPTIONS
    failed = 1
    OTHERS = 2.

CALL FUNCTION 'SMUM_XML_PARSE'
  EXPORTING
    xml_input = gv_xml_string " <-- We pass buffer variable getting from first fm
  TABLES
    xml_table = gt_xml_data   "<-- we get nodes xml and values
    return    = gt_return.

Please See images below

Convert XML to internal table

Get xml values from abap
After execute SUM_XML_PARSE We get nodes and values from XML into internal table abap
XML STRING INTO INTERNAL TABLE ABAP

Interesting for you: Send email with and excel file in ABAP

Leave a Reply

Your email address will not be published. Required fields are marked *

Go up