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

XML transformation encoding

Former Member
0 Likes
3,981

Hi all!

I'm using a SIMPLE TRANSFORMATION to generate an XML file that is sent to a legacy system. After the CALL TRANSFORMATION statement, I get the XML string, but it starts with:

<?xml version="1.0" encoding="utf-16"?>

My legacy system can read only UTF-8, so I need to change the encoding.

Reward points wait for the solver

This is my code:

CALL TRANSFORMATION zpp_transm_eol_f1a

SOURCE cin = ls_zf1a-vehicle_id_numb

RESULT XML gs_f1a_file_xml.

and this is the transformation:

<?sap.transform simple?>

<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">

<tt:root name="CIN"/>

<tt:template>

<Assemblies>

<Assembly>

<UniqueNumber>

<tt:value ref="CIN"/>

</UniqueNumber>

</Assembly>

</Assemblies>

</tt:template>

</tt:transform>

1 ACCEPTED SOLUTION
Read only

Former Member
2,008

I found the solution and want to share with all:

when you use CALL TRANSACTION statement, the XML string is encoded in UTF-16 or UTF-8 dependig by the type of the string itself. I mean:

1) this will be UTF-16:

data return_string type STRING.

call transformation my_transform

source ......

result xml return_string.

2) this will be UTF-8:

data return_string type XSTRING.

call transformation my_transform

source ......

result xml return_string.

Hope this will help sameone.

3 REPLIES 3
Read only

Former Member
2,009

I found the solution and want to share with all:

when you use CALL TRANSACTION statement, the XML string is encoded in UTF-16 or UTF-8 dependig by the type of the string itself. I mean:

1) this will be UTF-16:

data return_string type STRING.

call transformation my_transform

source ......

result xml return_string.

2) this will be UTF-8:

data return_string type XSTRING.

call transformation my_transform

source ......

result xml return_string.

Hope this will help sameone.

Read only

0 Likes
2,007

Thanks, your reply was really Helpful

Read only

0 Likes
2,007

Thanks for sharing the solution, I actually had this problem before, in my case the middle ware supports UTF-16 so I left it as it is, but I never figured it out.