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

how to encode values properly when using DOM

Former Member
0 Likes
804

Hello,

I am facing a kind of tricky problem. I am using DOM in ABAP (with the IXML library) to generate and render XML trees.

Basically all of that works fine.

The problem is that the DOM elements (namely attributes and text node) allow only for <b>STRING</b>-typed arguments to set their value.

This is problematic, because I want to exchange data with other systems. For that I would use the encoding that SAP uses in the asXML format. In that format a Date for example is represented in the form YYYY-MM-DD (instead of the internal SAP format: YYYYMMDD) and a negativ number as -XXX (instead of the internal SAP format: XXX-).

I would like to use an asXML-like value format, because that is based on international standards for expressing certain data types. But when using DOM I don't know how to convert a value into such a representation.

I thought about converting ABAP data into asXML and then creating a fitting XSLT to circumvent the necessity of "manually" converting values into the correct format, but the data has a linear structure which would require complicated, crude and inperformant XSLT code to convert into a hierarchy.

So the basic question is: how can I render a non-character-like value (e.g. a Date) into a proper asXML-like string representation (YYYY-MM-DD)?

I have tried a lot and also read all documentation on this that I could find. Does anybody have a clue on this?

Thank you so much.

Christian

2 REPLIES 2
Read only

Former Member
0 Likes
685

Just to save others the search, who might have a similar problem: There is a function module called SDIXML_DATA_TO_DOM. This function generates a DOM node that contains the correctly represented value. It can use any type that you hand over.

To this node one can then add any required attributes and finally plug it into one's DOM tree.

If one needs to 'escape' a value and then insert it as value of an attribute - then doing the following is possible:

- use SDIXML_DATA_TO_DOM on your value

- extract the text content of generated XML node

- use this value (which now has the proper, XML-converted representation of your value) to create your attribute with the IXML object library.

This approach produces some overhead of course, because a useless DOM Node gets created and discarded again, but that should be manageable.

There seems to be no object-oriented counterpart for this function module. There are other SDIXML* functions for which this also the case (e.g. schema generation from DDIC), so looking at this functions might be worthwile.

Christian

Read only

Former Member
0 Likes
685

Hello,

I'm now start working on a funcion to build a XML file from values returned from a function module. Can you help me in this? I have SAP version 4.6C.

Kind regards,

Ana