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

xml to abap

Former Member
0 Likes
742

Hi,

I've a question related with call transformation.

I need to parse an XML file into an ABAP structure. I have the XML but I don't the ABAP structure. I wonder to know if there is an "automatic" way to define an ABAP structure (itab) from my xml file in order to store in it my XML file.

thanks in advance

Aaron

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
676

Check....

CEP_DOC_PARSE_XML_AND_SAVE

CEP_XSTRING_PARSE_XML_CLASS

Hi,

I've a question related with call transformation.

I need to parse an XML file into an ABAP structure. I have the XML but I don't the ABAP structure. I wonder to know if there is an "automatic" way to define an ABAP structure (itab) from my xml file in order to store in it my XML file.

thanks in advance

Aaron

4 REPLIES 4
Read only

Former Member
0 Likes
677

Check....

CEP_DOC_PARSE_XML_AND_SAVE

CEP_XSTRING_PARSE_XML_CLASS

Read only

0 Likes
676

Thanks for your quick answer.

I don't know how to use, CEP_DOC_PARSE_XML_AND_SAVE. i think it's useless in this case. i can't find the way to give it my xml file.

I've tried CEP_DOC_PARSE_XML_AND_SAVE too, but it give me back an empty table. here is the code:

-


constants: srclen type i value 1024.

types: tsrclin(srclen) type x,

tsrctab type standard table of tsrclin.

data: file type string.

data srctab type tsrctab.

data st_srctab like line of srctab.

data strng_xml type xstring.

data: filelength type i.

data i_data like CHARACTERISTIC_VALS occurs 0.

data i_error like table of messages.

selection-screen begin of block b1.

parameters: p_path type localfile default 'D:\documentacion\MM\XML - XSLT\Invoice_5756.xml'.

selection-screen end of block b1.

file = p_path.

  • get XML

call function 'GUI_UPLOAD'

exporting filename = file

filetype = 'BIN'

importing filelength = filelength

tables data_tab = srctab

exceptions others = 1.

loop at srctab into st_srctab.

concatenate strng_xml st_srctab into strng_xml.

endloop.

CALL FUNCTION 'CEP_XSTRING_PARSE_XML_CLASS'

EXPORTING

pxstr_xml = strng_xml

tables

pt_classification = i_data

PT_ERROR_MSGS = i_error

EXCEPTIONS

PARSING_ERROR = 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.

-


could you help me with those FM???

many thanks

Read only

Former Member
0 Likes
676

😮

Read only

Former Member
0 Likes
676

No, there is no automatic way. But you can use the classes in the IXML package in order to parse and render your xml into a DOM tree. From this you can create an ABAP structure by using the functionality of RTTI.

This has nothing to do with call transformation, since there you need an already existing DDIC structure.

Regards,

Thomas