on 05-31-2007 10:36 AM
Dear All
I am trying to update the Description from JSP form. Through JCO we are calling the RFC of ABAP. We are passing these description from Java to RFC of ABAP and this RFC update the text in Database.
We have noticed that if there is some special character in description like as : or , complete description is not getting updated in to the SAP database.
Can anyone help me how to handle these special characters in Java. There may be N number of special characters. We want to generalize it. We want to replace these characters by s and z respectively.
For example : We want to update this description.
APPLERR H'4301 H'FA03 H'254C na Zagreb TC4 rijeen je cleaning procedurom, te je i kroz CSR odgovoreno da trap korekcija N01TCADG-0052 u bloku UPDC vie nije potrebna, te se moe izbaciti (AP143).
Uspjeno su zavrene HR17/CN-A3 FOA-e na tranzitnom nivou, te slijedi roll-out u dva termina 12/13.04 i 19/20.04. ETK je na sastanku isporučio SW, te ALEX i mini PLEX za sve objekte.
AP147. Poslati finalnu dokumentaciju za uvođenje paketa (implementacijsku instrukciju i sve popratne datoteke).
WHile updated text is as follows :
APPLERR H'4301 H'FA03 H'254C na Zagreb TC4 rije
N01TCADG-0052 u bloku UPDC vi
Uspje
sastanku isporu
AP147. Poslati finalnu dokumentaciju za uvo
Regards
Bhavishya
Hi Bhavishya,
Apparently your SAP database isn't configured to support Unicode. That would be the first solution to your problem, but I can imagine it's a bit drastic to convert your DB.
A second solution would be to encode the input description to ASCII before storing it in the database. When reading from the database, decode again to Unicode. This way, no information is lost. A suitable encoding would be Base64. e.g.
String description = "unday ebra";
String descriptionBase64 = new sun.misc.BASE64Encoder().encode(
description.getBytes("UTF-8")); // ""
// store descriptionBase64 in the DB
// later, when reading descriptionBase64 from the DB
String description2 = new String(
new sun.misc.BASE64Decoder().decodeBuffer(descriptionBase64), "UTF-8");
Instead of using Sun's implementation, a better alternative is to use the open source implementation
org.apache.commons.codec.binary.Base64
from Commons Codec .The 3rd approach is indeed to normalize the description by replacing all special characters with their ASCII equivalent. A rather easy solution is as follows:
String description = "unday ebra";
String descriptionNormalized = sun.text.Normalizer.normalize(
description, sun.text.Normalizer.DECOMP, 0).replaceAll(
"[^p{ASCII}]", "");
sun.text.Normalizer
decomposes the string, e.g. "éàî" becomes "e´a`i^", after which non-ASCII characters are being removed using a regular expression.Again, note that it's usually a bad idea to use sun.* packages, see <a href="http://java.sun.com/products/jdk/faq/faq-sun-packages.html">note about sun.* packages</a>. The above code only works with J2SE 1.4 and J2SE 5.0, but it breaks in J2SE 6.0 (where
java.text.Normalizer
became part of the public API ;-). A good open source implementation can be found here: <a href="http://icu-project.org/">ICU4J</a> (com.ibm.icu.text.Normalizer
).Kind regards,
/Sigiswald
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI
good
go through this link,hope this ll help you to solve your problem
thanks
mrutyun^
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
java cade
String s="unday ebra";
s=s.replace("","s");
s=s.replace("","z");
after this two stmt String s will contain sunday zebra
Regards,
Beevin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Josheph
Thanks for your reply.
I was already aware of this solution. But in this case we already knew the special characters. But in realtime there may be N numbers of the special characters. I want to handle all of them. I do not feel that it would be possible to handle each and every special character in such a way.
Is there any possibility to handle such cases. Or is there any standard class method which can handle it.
Best Regards
Bhavishya
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.