Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Function module for uploading XML file to inner table?

Former Member
0 Likes
1,643

Hi,

I need a function module(s) for uploading XML file to inner table.

Thanks a lot for help,

Regards,

Mindaugas

1 ACCEPTED SOLUTION
Read only

athavanraja
Active Contributor
0 Likes
1,031

you can use GUI_UPLOAD to load xml to internal table. but if you want to read the (element) values in the xml and map it to row/columns in an internal table then you have to parse the xml . there are multiple options available for this. the simplest(for a abaper) would be using FM SMUM_XML_PARSE

5 REPLIES 5
Read only

Former Member
0 Likes
1,031

for example, we have FM called ALSM_EXCEL_TO_INTERNAL_TABLE, so maybe we have some analogic FMs for reading XML into inner table?

Regards,

Mindaugas

Read only

athavanraja
Active Contributor
0 Likes
1,032

you can use GUI_UPLOAD to load xml to internal table. but if you want to read the (element) values in the xml and map it to row/columns in an internal table then you have to parse the xml . there are multiple options available for this. the simplest(for a abaper) would be using FM SMUM_XML_PARSE

Read only

0 Likes
1,031

calling of FM SMUM_XML_PARSE looks like this:

CALL FUNCTION 'SMUM_XML_PARSE'

EXPORTING

XML_INPUT = inpdatax

TABLES

XML_TABLE = t_xml

RETURN = t_err.

I assume that parameter inpdatax is a single string of the XML document and in order to prepare this string, I have to use 'GUI_UPLOAD', thew result of calling SMUM_XML_PARSE will be inner table t_xml containing XML document, correct?

Flow of steps of transforming XML file to inner table of ABAP is not clear for me...

Regards,

Mindaugas

Read only

0 Likes
1,031

the main thing is that I do not know how to make inpdatax if I have XML file...

CALL FUNCTION 'SMUM_XML_PARSE'

EXPORTING

XML_INPUT = inpdatax

TABLES

XML_TABLE = t_xml

RETURN = t_err.

Thanks in advance.

Mindaugas

Read only

0 Likes
1,031

here is the code sample.


data:xmldata type xstring .
data: begin of xml_tab occurs 0,
           raw(line_size) type x,
        end   of xml_tab .
data: size type i .
data: result_xml type standard table of smum_xmltb .
data: return type standard table of bapiret2 .

call function 'GUI_UPLOAD'
    exporting
      filename            = filename
      filetype            = 'BIN'
      has_field_separator = ' '
      header_length       = 0
    importing
      filelength          = size
    tables
      data_tab            = xml_tab
    exceptions
      others              = 1.

call function 'SCMS_BINARY_TO_XSTRING'
  exporting
    input_length       = size
*   FIRST_LINE         = 0
*   LAST_LINE          = 0
 importing
   buffer             = xmldata
  tables
    binary_tab         = xml_tab
 exceptions
   failed             = 1
   others             = 2
          .
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
CALL FUNCTION 'SMUM_XML_PARSE'
  EXPORTING
    xml_input       = xmldata
  TABLES
    xml_table       = result_xml
    return          = return .