cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Special characters(Russian) using DynamicConfiguration

shweta_walaskar2
Contributor
0 Kudos

Hi,

I have a mail-RFC scenario where I am using adapter-specific message attributes and DynamicConfiguration to retrieve mail subject.It works fine.

We have a problem when the subject contains Russian special characters.In this case,whole mail subject gets converted into an irrelevant string.

Can anyone please suggest how to handle special characters in DynamicConfiguration using ASMA .

Thanks a lot for your help in advance.

Regards,

Shweta

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

Are the characters visible in XI ? If so then Is you backend R/3 system an ECC System. If So change the encoding on RFC destination to Unicode and it should be fine. You can confirm that your backend system is Unicode enabled using the "Unicode Test" on the toolbar. Otherwise if your backend system is an older SAP syste e.g SAP 4.6c then you might need to update the codepage on the RFC destination. See SAP Notes:

663089

RFC Bit Options in SM59

Setting RFC bit options for RFC destination.

613389

ALE SAP System Group with Unicode Systems

Connecting several SAP systems with ALE; at least one of the systems is a Unicode system.

793847

ALE SAP System Group (Unicode) with Subsystem (non-Unicode)

Connecting a Unicode SAP system with a non-Unicode external subsystem.

656350

Master Data Transfer from Unicode to MDMP Systems with ALE

Exchanging language-dependent master data between Unicode and MDMP.

597105

Character Strings Displayed Incorrectly in Update

Displaying characters in international environments (Japanese, for example).

Thanks

Damien

shweta_walaskar2
Contributor
0 Kudos

Hi Damien,

Thanks for your reply.

I have checked that the backend system is Unicode system.

Also,I can see these characters correctly in Payload for inbound message in XI.

Thanks again.

Regards,

Shweta

Former Member
0 Kudos

Hi

So in the RFC connection that connects your XI instance to your ECC instance go to the MDMP * Unicode tab. In here make sure the "Unicode" radio button is selected.

Thanks

Damien

shweta_walaskar2
Contributor
0 Kudos

Hi Damien,

I checked it and found that Unicode is not selected.But I wonder how is it working for other scenarios.

Thanks a lot for your help.

Regards,

Shweta

shweta_walaskar2
Contributor
0 Kudos

Hi Damien,

I have selected unicode option too,still it doesn't work.

As far as I can understand,this is not a problem with the RFC call since mail subject is passed as a parameter to this RFC.

But I checked Dynamic configuration results in SXI_MONITOR and found that the subject has incorrect value before it is passed to RFC.

So this must be handled while retrieving subject in DynamicConfiguration itself.

Can you suggest something.

Thanks.

Regards,

Shweta

stefan_grube
Active Contributor
0 Kudos

Could you post the value here?

shweta_walaskar2
Contributor
0 Kudos

Hi,

Thanks for the reply

For message subject 051106/П017493/ it is returning the value as

=?KOI8-R?B?Rnc6IDEwMjEwMTMwLzA1MTEwNi/wMDE3NDkzLw==?=

Regards,

Shweta

stefan_grube
Active Contributor
0 Kudos

That means you have a base64 String.

=? and ?= are delimiters.

KOI8-R is the codepage (Russian)

B stands for base64

So you need an UDF. First identify the =?, to check if you need to convert.

Extract the base64 String:

Rnc6IDEwMjEwMTMwLzA1MTEwNi/wMDE3NDkzLw==

decode the String and change the result from the given codepage to UTF-8

Regards

Stefan

shweta_walaskar2
Contributor
0 Kudos

Hi Stefan,

This is really great.

I can extract the string but can you please let me know how to decode this in order to convert this to UTF-8.

Thanks a lot.

Regards,

Shweta

stefan_grube
Active Contributor
0 Kudos

Thanks to following blog, I found a solution.

/people/farooq.farooqui3/blog/2008/05/22/decode-base64-incoming-encoded-information-in-sap-xipi-using-java-mapping

Create a UDF with import statement

sun.misc.BASE64Decoder

For testing purpose I put that code:

String subject = "Rnc6IDEwMjEwMTMwLzA1MTEwNi/wMDE3NDkzLw==";
String charset = "KOI8-R";
try {
    BASE64Decoder decoder = new BASE64Decoder();
    byte b[] = decoder.decodeBuffer(subject);
    String decode =	new String(b, charset);
    return decode;
} catch (Exception e){
   return e.getMessage();
}

All you have to do, is finding the identifiers, providing the Strings and verifying, that there is a "B" which stands for base64.

There could be also for example a Q, that means quoted-printable, like this:

=?utf-8?Q?Auftragsbest=C3=A4tigung?=

Regards

Stefan

stefan_grube
Active Contributor
0 Kudos

btw: The result is:

Fw: 10210130/051106/u041F017493/

shweta_walaskar2
Contributor
0 Kudos

Hi Stefan,

This is really a great help.I'll try it out.

However,I tried to change the encoding in mail adapter to None and Quoted Printable ,still I get the same result (with B).I think,it should have changed.

Thanks a lot.

Regards,

Shweta

shweta_walaskar2
Contributor
0 Kudos

Hi Stefan,

I have tested this and it works perfectly fine.

This has really resolved the issue.

Many thanks for your help again

Regards,

Shweta

stefan_grube
Active Contributor
0 Kudos

> However,I tried to change the encoding in mail adapter to None and Quoted Printable ,still I get the same result (with B).I think,it should have changed.

This is intended for the content, not for the subject.

The subject is created by the mail sender, you cannot influence this in the sender mail adapter. It is an email standard that non-ascii characters are encoded.

Regards

Stefan

shweta_walaskar2
Contributor
0 Kudos

Hi Stefan,

Thanks for the information.

It has resolved our long lasting issue.

Thanks again.

Regards,

Shweta

shweta_walaskar2
Contributor
0 Kudos

Hi,

Thanks a lot to all who have helped in resolving this issue.

Regards,

Shweta

shweta_walaskar2
Contributor
0 Kudos

Hi,

I am not sure if I should create a new thread or continue the same one,since the problem is same.

This was resolved using the Base64Decoder mentioned by Stefan.

Now we again have the same problem,when I tried to check the message subject in DynamicConfiguration segment,I found that this time the subject was encoded with Quoted-printable encoding and hence my mapping failed.

The mail client is same.

Hence ,I need to know how did this encoding of mail subject changed from base64 to Quoted-printable.

Can anyone please help in this?

Thanks.

Regards,

Shweta

Former Member
0 Kudos

Hi,

My guess but i am not sure about this thing - i think in the header of the mail msg, the content encoding is Quoted Printable....so in XI in SXMB_MONI select your msg and in inbound msg in SOAP header just see if some parameter is having Quoted Printable as content encoding..........and because of this, your msg is having Quoted Printable in the mail subject encoding.........

Regards,

Rajeev Gupta

shweta_walaskar2
Contributor
0 Kudos

Hi Rajeev,

This is the content of the subject that they are sending:

10210130/290109/П000960

How can I check if it is base64 or Quoted-Printable?

Thanks.

Regards,

Shweta

Former Member
0 Kudos

Hi Shweta,

How can I check if it is base64 or Quoted-Printable? - As i said in the above post, this is just my guess - in XI in SXMB_MONI select your msg and in inbound msg in SOAP header just see if some parameter is having Quoted Printable as content encoding..........and because of this, your msg is having Quoted Printable in the mail subject encoding.........

or may be you can ask the sender of the mail that was the mail sent is having content encoding as Quoted Printable?

Regards,

Rajeev Gupta

Edited by: RAJEEV GUPTA on Apr 1, 2009 2:27 PM

shweta_walaskar2
Contributor
0 Kudos

Hi Rajeev,

This is in SOAP message:

<xim:Mail xmlns:xim="http://sap.com/xi/XI/Mail/30" encoding="base64">

So,it clearly says that encoding is base64,then why does DynamicConfiguration has Quoted-Printable encoding

Regards,

Shweta

Answers (2)

Answers (2)

shweta_walaskar2
Contributor
0 Kudos

The problem mentioned in previous post was answered and solved,now the same problem has occured but because of different reason and need to be resolved

henrique_pinto
Active Contributor
0 Kudos

Hi Shweta,

Stefan already mentioned this in his post!

In the converted string, you have something like:

=?<charset>?<enconding>?<content>?=

So, basically you need to read the <enconding> value from the input string and then make a IF statement to decide which decoding code you're gonna execute.

In the Base64 example, <enconding> = B.

In the QuotedPrintable example, <encoding> = Q.

Please check if in your case it's like that.

Best,

Henrique.

shweta_walaskar2
Contributor
0 Kudos

Hi Henrique,

I agree.

This is the case,and I can see 'Q' in the string in DynamicConfiguration.

So I came to know that it is Quoted printable.

Before this,it was tested a number of times when the string used to contain 'B'.

Now ,first thing is,why it has changed and secondly,I can check whether its B or Q,but then my Base64Decoder wont work and I need Quotable print decoder.

I tried to write a decoder but I get an error that required API's are missing.

Do we have such utility in sun.misc.* package?

Can you help in this.

Thanks.

Regards,

Shweta

stefan_grube
Active Contributor
0 Kudos

I have found this:

http://java.sun.com/j2ee/1.4/docs/api/javax/mail/internet/MimeUtility.html

You need the library mail.jar for this.

Regards

Stefan

henrique_pinto
Active Contributor
0 Kudos

Another option of Quoted-printable decoder: http://commons.apache.org/codec/apidocs/org/apache/commons/codec/net/QuotedPrintableCodec.html

it also needs a special API.

Download it from here: http://commons.apache.org/codec/

Best,

Henrique.

shweta_walaskar2
Contributor
0 Kudos

Hi both,

Thanks a lot for the information.

I'll try it out and let you know if it works.

Regards,

Shweta

shweta_walaskar2
Contributor
0 Kudos

Hi Stefan,

I have created an IA with mail.jar and written a decoder:

String charset = "KOI8-R";

try {

MimeUtility decoder = new MimeUtility();

String b = decoder.decodeText(a) ;

return b;

} catch (Exception e){

return e.getMessage();

}

But I get an error:

MimeUtility() has private access in javax.mail.internet.MimeUtility MimeUtility decoder = new MimeUtility();

even though,in the API it is defined as:

public class MimeUtility

Any idea?

Thanks.

Shweta

henrique_pinto
Active Contributor
0 Kudos

Check out the Javadoc: http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/mail/internet/MimeUtility.html

There's no constructor; all of its methods are static.

Edit: actually, Im not sure your code will work as is.

Try this out:


String subject = "Auftragsbest=C3=A4tigung";
String charset = "UTF-8";

try {
	InputStream is =
		new ByteArrayInputStream(subject.getBytes());
	InputStream dis = MimeUtility.decode(is, "quoted-printable");

	ByteArrayOutputStream out = new ByteArrayOutputStream();
	byte[] b = new byte[4096];
	for (int n;(n = dis.read(b)) != -1;) {
		out.write(b, 0, n);
	}
	return(out.toString(charset));

} catch (Exception e) {
	//Implement catch...
}

Also, notice that the MimeUtility.decode() method supports other encoding methods as well, including "base64". Maybe you could just use this method with different values for the 2nd parameter of the method in order to properly decode the input string.

Regs,

Henrique.

henrique_pinto
Active Contributor
0 Kudos

Your UDF could be something like this:


String output = null;

String strs[] = input.split("\\?");
String charset = strs[1];
String encoding = null;
switch (strs[2].charAt(0)) {
	case 'Q' :
		encoding = "quoted-printable";
		break;
	case 'B' :
		encoding = "base64";
		break;
	default :
		break;
}
String subject = strs[3];

try {
	InputStream is = new ByteArrayInputStream(subject.getBytes());
	InputStream dis = MimeUtility.decode(is, encoding);

	ByteArrayOutputStream out = new ByteArrayOutputStream();
	byte[] b = new byte[4096];
	for (int n;(n = dis.read(b)) != -1;) {
		out.write(b, 0, n);
	}
	output = out.toString(charset);

} catch (Exception e) {
	//implement catch...
}
return output;

where input is the input string.

For test purposes, use

String input = "=?KOI8-R?B?Rnc6IDEwMjEwMTMwLzA1MTEwNi/wMDE3NDkzLw==?=";
or
String input = "=?utf-8?Q?Auftragsbest=C3=A4tigung?=";

Regs,

Henrique.

shweta_walaskar2
Contributor
0 Kudos

Hi Henrique,

This works perfectly fine and the problem is resolved .

Thanks a lot for your help.

Best Regards,

Shweta

markangelo_dihiansan
Active Contributor
0 Kudos

Hi,

We have had a scenario that goes like this:

R/3 --> XI --> Vendor

If a Russian character is inputted in R/3, it is displaying as success in SXMB_MONI but message is failing in Adapter Engine. We asked the vendor to adjust their input to avoid problems in the adapter engine. I'm not sure if this can be handled by Java mapping.

hope this helps,

shweta_walaskar2
Contributor
0 Kudos

Hi Mark,

Thanks for your reply.

It is not possible for us to avoid such characters in mail subject.

Regards,

Shweta