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

Issue Writing XML Files to Application Server

Former Member
0 Likes
933

I'm using CALL TRANSFORMATION to convert an internal table to an XML string (the data object into which it is transformed is "string").

I'm using OPEN DATASET to write it out to the application server. When I tried reading it back in I got a code page conversion error. I looked at the file in a hex editor (I downloaded it to my PC) and there are 3 strange characters at the beginning of the file. I have no idea what these are but I suspect that these are causing the problem when trying to read the file back in, again with using OPEN DATASET.

My question is, what's the best way to write out an XML string generated by CALL TRANSFORMATION so that I can read it back it (and others can) with minimal effort? Is there a "lowest-common-denominator" way to use OPEN DATASET for input/output? Or is there something I need to do to the XML string before I write it out?

P.S., I noticed that the XML generated had "<?xml version="1.0" encoding="utf-16"?>" at the top. That line isn't in the ST program I wrote so SAP is putting it there. I'm not sure what that means or if it's relevant

MANY THANKS!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
828

Hello SK,

In call transformation there are some optional switches which you can use to switch the heading information off.



CALL TRANSFORMATION ID
             SOURCE ITAB = ITAB[]
             OPTIONS xml_header = 'OFF'
              RESULT XML xml_string.

In some of the SAP versions call transformation produces '#', which is actually non printable char so after transformation

using offset you can remove that char and then download it to application server.



* Suppose you have '#' at offset 10 in xml_string.

xml_string+10(1) = ''. --> This will remove that special char.

Hope this helps!

Thanks,

Augustin.

5 REPLIES 5
Read only

Former Member
0 Likes
829

Hello SK,

In call transformation there are some optional switches which you can use to switch the heading information off.



CALL TRANSFORMATION ID
             SOURCE ITAB = ITAB[]
             OPTIONS xml_header = 'OFF'
              RESULT XML xml_string.

In some of the SAP versions call transformation produces '#', which is actually non printable char so after transformation

using offset you can remove that char and then download it to application server.



* Suppose you have '#' at offset 10 in xml_string.

xml_string+10(1) = ''. --> This will remove that special char.

Hope this helps!

Thanks,

Augustin.

Read only

0 Likes
828

Thank you very much. I will try the XML_HEADER option as well but I already used the offset technique and it works fine.

Read only

0 Likes
828

For everyone's information, I found out, quite by accident, that these three bytes that were causing me problems was something called a "BOM" or "Byte Order Mark". I've included the Wikipedia link to find out more.

[http://en.wikipedia.org/wiki/Byte-order_mark|http://en.wikipedia.org/wiki/Byte-order_mark]

I am still confused as to why I was not able to use CALL TRANSFORMATION to serialize an XML file that contains a BOM into an internal table since SAP put it there to begin with. As stated above, there is a workaround but it's still confusing...

Read only

Former Member
0 Likes
828

Those chars seem to be encoding type, so perhaps they are triggered by the type of data you are trying to convert.

Read only

0 Likes
828

Perhaps. My knowledge of Unicode is woefully lacking. The system I'm working on does not contain any text data that is not based on the Latin alphabet; in other words, it's all English.

I did use the

OPTIONS xml_header = 'without_encoding'

and it removed the BOM from the beginning of the file.