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

Dynamically read complex XML without creating dictionary structure

Karan_Chopra_
Active Participant
0 Likes
2,868

Hello experts.

Need help in creating and then updating XML file in abap.

Problem is my Xml file is complex with 200 + fields and deep hierarchy. I know XML is usually created with XSLT tool in abap and dictionary structure is created but in my case it will be really cumbersome and moreover hierarchy might not be fixed in XML.

Is there a way to create xml without creating dictionary structure and convert data to internal table dynamically?

9 REPLIES 9
Read only

Sandra_Rossi
Active Contributor
0 Likes
2,631

No need of ABAP Dictionary.

There are many examples in the Web, especially in the official ABAP Documentation (CALL TRANSFORMATION).

Read only

Karan_Chopra_
Active Participant
0 Likes
2,631

I checked the same but everywhere they create dictionary table or creating local structures .

Do you have any link where i can find xml created dynamically.

Read only

matt
Active Contributor
0 Likes
2,631

Your question was how to do it without creating a dictionary structure. Now you're saying that you don't want to create a local structure either.

You can create local structures dynamically using RTTS. Maybe that would work for you.

It's a bit odd to say that the XML won't be fixed. Why is that? Obviously the data held in it will vary, but usually you expect XML to conform to a specific schema.

Of course there's absolutely nothing to stop you reading the XML file a line at a time and writing a parsing program in ABAP.

You might also look at the iXML library. https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abenabap_ixml_lib.htm

Read only

Karan_Chopra_
Active Participant
0 Likes
2,631

Sorry for the confusion. My point was as XML consist 200 plus fields, creation of same as dictionary or local structure is something cumbersome. Also there might be cases when certain nodes might be empty.

Even if we say only nodes are empty and xml base structure does not change then is it possible to read the same without specifically creating data structure?

Or then other option is RTTS.

Read only

matt
Active Contributor
2,631

It's always possible. Transformations and XLST are just programs. Written in a programming language. Anything written in one language can be written in another. Worst case (and I've seen it done), you can use the normal text processing facets of ABAP to read the XML a line at a time and deal with it that way.

However, if you've got the XSD of the XML, then you can hijack SPROXY functionality to create the structures and transformations automatically. https://blogs.sap.com/2015/12/14/create-xml-files-xsd-compliant-exploiting-sproxy-functionalities-an.../

This is exactly how I wrote a ZUGFeRD parser.

Read only

joltdx
Active Contributor
2,631

Yes, convincing a computer to do what you want it to (aka programming) is cumbersome at times. 🙂

Sandra and Matthew have already provided some directions for you. But could you clarify for me as I'm not sure I understand what it is you want to do... In the title there is "Read", then in the text there "creating and then updating"... Where are you getting your data from to start with? And what are you doing with it? Are you updating something in SAP based on it? Or are you sending something out from SAP to another system? Or are you using SAP as some kind of XML transformation engine?

Read only

Karan_Chopra_
Active Participant
0 Likes
2,631

@jorgen_lindqvist41 Actually I need to first read the XML file which comes from interface and then based on certain mapping I need to update the XML with SAP data and send back to third party interface.

My first problem is XML has infact 100s of field and those also deep structures something as attached. This structure goes till 900..

So I am not sure what should be best approach.

Hope you get my point

Read only

joltdx
Active Contributor
0 Likes
2,631

Oh, I get it. You need to do all of the things... And from what I can tell, you're in for quite a bit of work... I can't give you any better advice then than to have fun! 🙂

Read only

Sandra_Rossi
Active Contributor
2,631

If your program receives an XML document, and you need to just update a few nodes, then go to IXML or SXML, as it would be a useless effort to create a type with many nodes that you don't need.