cancel
Showing results for 
Search instead for 
Did you mean: 

Handling THAI charecters in sap XI

Former Member
0 Kudos

Hi Team,

we are working on webservice to RFC.

Where webservice side dealers enter a data in to English and thai.When they enter in eglish request coming to CRM and CRM giving response back. everything looks fine.

When dealer enters in thai charecters,here we are facing the problem.

webservice sending thai charecters to CRM thought sap xi.I can see thai charecters in SAP CRM.in turn CRM giving resonse back to CRM there also i can able to see te thai text.After convertion Xi is converting that thai data in to "??????????".

Inbound message coming from CRM :

<CUST_TITLE>คุณ</CUST_TITLE>

  <FLEET_CODE>******</FLEET_CODE>

  <FLT_APPR_CODE />

  <SEX>2</SEX>

  <FNAME>อรรถวิทย์</FNAME>

  <LNAME>ศฤงฆานนท์</LNAME>

  <CNAME1>******</CNAME1>

After pipeline steps in moni below i sthe output message:

  <soapenv:Header />

- <soapenv:Body>

- <ns1:ConsumerRetrieveResponse OperationStatus="succeeded">

- <ns2:Consumer ns2:ReadOnly="false" ConsumerType="Person" ConsumerID="0001212044">

- <ns2:ConsumerName>

- <ns6:PersonName>

  <ns6:NameElement ns6:ElementType="FirstName">?????????</ns6:NameElement>

  <ns6:NameElement ns6:ElementType="LastName">?????????</ns6:NameElement>

  <ns6:NameElement ns6:ElementType="Title">???</ns6:NameElement>

  </ns6:PersonName>

  </ns2:ConsumerName>

- <ns5:Addresses>

here we are using java mapping to convert saop req to xml and xml to soap response.Attaching java mappings below.

Please suggest me where is the problem.

Regards,

Narendra

Accepted Solutions (0)

Answers (4)

Answers (4)

stefan_grube
Active Contributor
0 Kudos

This is the cause of your issue:


public  String inputStreamToString(InputStream in) {




int c = 0;



while ((c = isr.read()) != -1) {




buf.append((char) c);

This code does not make any sense for a code page which is not single byte.

Note: A UTF-8 character could have one to four bytes.

When there is for example a letter which has two bytes, ten your code creates two different letters from one. That creates your "?" in the output.

stefan_grube
Active Contributor
0 Kudos

Use this code:



byte[] bain = new byte[in.available()];


in.read(bain);


String payload = new String(bain);
rodrigoalejandro_pertierr
Active Contributor
0 Kudos
0 Kudos

This document might be helpful:

How To Work with Character Encodings in Process Integration

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/502991a2-45d9-2910-d99f-8aba5d79f...

Liz

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Narendra,

Do byte transformations first before manipulating payloads of a different encoding. A sample code for converting ISO-8859-1 to UTF-8:

Where sourceXML is a String

byte[] latin1 = sourceXML.getBytes("ISO-8859-1");

byte[] utf8 = new String(latin1, "ISO-8859-1").getBytes("UTF-8");

String xml = new String(utf8, "UTF-8");

xml = xml.replaceAll("ISO-8859-1", "UTF-8");

The last line is for replacing the entry for the prolog.

In your case, convert ISO-8859-11 to UTF-8.

Hope this helps,

Mark

Former Member
0 Kudos

Hi Mark,

Thanks for your quick response.

Here SaopToXml.java is using to convert  ISO-8859-1 to UTF-8.that is working fine.

Xi is handling request message properly.in the response message we are using 2 java codes which i have uploaded above.XMLTOSOAP .java and xml formatter.java. i guess here we are facing some problem.

But i could not able to identify the problem.

Could you please suggest.

Regards,

Narendra

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Narendra,

ISO-8859-1 is Latin 1, you should use ISO-8859-11

http://en.wikipedia.org/wiki/ISO_8859

Hope this helps,

Mark

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Narendra,

ISO-8859-1 is Latin 1, you should use ISO-8859-11

http://en.wikipedia.org/wiki/ISO_8859

Hope this helps,

Mark

Former Member
0 Kudos

Hi Mark,

i have changed as per your suggestion.But it is giving more "???????" for even eng text.We should handle both english and thai in the same code.

So what can we do

Regards,

Narendra