on 02-03-2009 1:05 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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
> 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
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
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
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
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
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.
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
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.
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.
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,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.