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

Change XML Encoding to UTF-8

Former Member
0 Likes
3,696

Dear SDNers:

Hello!

I face an issue of sending some XML documents from SAP to a non SAP System. This non SAP System stores XML documents in UTF-8 encoding format. When I create an XML document using CALL TRANSFORMATION in ABAP, the XML code generated has encoding as "ISO-...". Could anyone of you please guide me on how to have this changed to UTF-8?

In case of no solution, I would eventually have to pick the XML generated code and replace the "ISO-..." thing with "UTF-8" at runtime within the program. However, I feel that's not a quality method.

So, if anyone of you can suggest/opine of something better, it would be truly appreciated and rewarded.

--

Have a Nice Day!

Vivek.

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
2,377

Hello Vivek

If you are working on 6.40 already perhaps the following classes may be helpful for converting between different encodings:

- <b>CL_ABAP_CONV_IN_CE</b> (<i>Code Page and Endian Conversion (System Format -> External)</i>)

- <b>CL_ABAP_CONV_OUT_CE</b> (<i>Code Page and Endian Conversion (System Format -> External)</i>)

- <b>CL_ABAP_CONV_X2X_CE</b> (<i>Code Page and Endian Conversion Between External Formats</i>)

Regards

Uwe

3 REPLIES 3
Read only

uwe_schieferstein
Active Contributor
0 Likes
2,378

Hello Vivek

If you are working on 6.40 already perhaps the following classes may be helpful for converting between different encodings:

- <b>CL_ABAP_CONV_IN_CE</b> (<i>Code Page and Endian Conversion (System Format -> External)</i>)

- <b>CL_ABAP_CONV_OUT_CE</b> (<i>Code Page and Endian Conversion (System Format -> External)</i>)

- <b>CL_ABAP_CONV_X2X_CE</b> (<i>Code Page and Endian Conversion Between External Formats</i>)

Regards

Uwe

Read only

0 Likes
2,377

Hello Uwe:

Currently we are on 6.20. But an upgrade is very near and I should expect these Classes to be handy then. I will explore them individually and post back. However, regarding my issue: the XML code generated by program is something like:

<?xml version="1.0" encoding="iso-8859-1"?>#<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0"><asx:values><SOURCE>42</SOURCE>

<?xml version="1.0" encoding="iso-8859-1"?>#<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0"><asx:values><SOURCE>42</SOURCE>.......

My need here is to replace the - encoding="iso-8859-1" with "UTF-8". So if you suggest proper methods to do so then it will be a good step for me.

Thanks for the relevant information anyways.

Have a nice day!

Read only

uwe_schieferstein
Active Contributor
0 Likes
2,377

Hello Vivek

The classes I mentioned are available on 6.20, too.

When I do XML transformations on our 6.40 unicode system the encoding is utf-8.

To replace the "ISO-..." with "utf-8" is a simple task. However, I do not know if it is necessary to convert the byte stream of the XML string as well. But you could easily find out.

Regards

Uwe