‎2008 Mar 02 8:23 PM
Hi,
I need a function module(s) for uploading XML file to inner table.
Thanks a lot for help,
Regards,
Mindaugas
‎2008 Mar 04 9:30 AM
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
‎2008 Mar 02 9:23 PM
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
‎2008 Mar 04 9:30 AM
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
‎2008 Mar 04 7:52 PM
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
‎2008 Mar 04 9:29 PM
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
‎2008 Mar 05 5:00 AM
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 .