tags:

views:

936

answers:

5

My company is working on a project that needs to read XML files within SAP ABAP.

  1. When the XML file has no data for a particular tag it omits that data.
  2. Some tags are self closing. e.g. <tag />

The SAP developer says that to read the XML document he first parses the document into an ABAP XML structure. This process fails on point 2. He must then create an XSLT to turn that data into an internal data structure, and that fails on point 1 therefore making the task very difficult to achieve within ABAP. Is that definitely the case and is there then no way of reading the specific fields that we need?

A: 

You can just read the file (using open dataset) and then parse the XML using string functions like find. Its ugly and could be A LOT of work, but you can definitely do it.

Bryan Cain
A: 

I'd suggest you apply the XSLT first to bring the XML content into a form the ABAP processor is able to read. There's also iXML (take a look at the sample programs BCCIIXML*), but it's rather slow and cumbersome to use...

vwegert
A: 

There is a tutorial at heidoc.net/joomla/development-mainmenu-31/22-sap--xslt/15-sapxslt that might help, also the SDN (SAP Developer's Net) has some articles on it. I've found some references at http://help.sap.com/abapdocu/en/ABENST%5FABEXA.htm

Just google it.

Steven Oldner
+1  A: 

The best place to start with XML parsing in ABAP is the SAP XML Library.

It is arguably a really bad idea to try and write your own parsing algorithm - let someone else (SAP, in this case) do the hard work for you.

Chris Carruthers
A: 

Hi guys, In case someone reads this blog and wonders: You might be able to use some checks with the cond statement like which can start like:

tt:cond check="not-initial(

or

tt:cond using="exist(ref('$Styles'))"

I used it with the Simple Transformation on EXCEL sheets.

Regards,

Edwin Glaser

Edwin Glaser