on 01-03-2011 4:56 AM
hi experts,
I have got a payload, which has got the character "&" in many fields,and that needs to be replaced with any other caharcter to make the payload suitable to work with in the integration engine.
please suggest possible solutions to my problem.
Thank you,
Shreya.
Hi Shreya,
here you can write a simple User defined function in mapping to replace all '&' with character of your choice. Below I have written a simple java code to do so . The name of the UDF is function. For input "&g&jo" it gives output "ANDgANDjo". You can change the value of string replaceWith with any value of your choice. Then you will obtain the desired output. This UDF has to be put in every mapping to target xml message.
public class replaceChars {
public static String function(String s)
{
try
{
int i;
char r='&';
String replaceWith="AND";
String d="";
for(i=0;i<s.length();++i)
{
if(s.charAt(i)==r)
{
d+=replaceWith;
continue;
}
else
{
d+=s.charAt(i);
}
}
s=d;
}
catch(Exception e)
{
e.printStackTrace();
}
return s;
}
public static void main(String[] args) {
String s="&g&jo";
System.out.println(function(s));
}
}
regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
If the source system is ECC and the payload is either an Idoc or RFC, then the special characters can be handled by making your RFC destination at the Sender side (ECC) as Unicode compatible as follows.
SM59>R3 connections> RFC destination> Special options tab> check the checkbox for Unicode.
If not the case mentioned above, follow this SDN guide:
[http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/502991a2-45d9-2910-d99f-8aba5d79fb42]
Regards,
Kalpana.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You have possible to write the UDF to convert the Ampersend chacter to other chacter.
Thank you,
Sateesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
As Stefen explained clearly u cannot achieve this just with a UDF.
To solve this problem i have 3 options...
1.Ask the source file provider to change the & to & and send the payload to the PI/XI.
2.Use an adapter module to convert the incoming message to proper format and sent to Integration engine(I dont recommend this)
3.Use an Java mapping to convert the incoming message to proper format.
Now step by step review which is best possible for u..
Now if u want to for 3 option search for java mapping and check for the code to convert the characters.
If u cannot find let us know any1 here wil provide the code
Here is the method in Java mapping u need to incorporate
static String stringFormat(String str) {
str = str.replace("&", "&");
str = str.replace("'", "'");
str = str.replace("<", "<");
str = str.replace(">", ">");
str = str.replace("\"", """);
return str;
}
Babu
Edited by: hlbabu123 on Jan 3, 2011 4:09 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shreya,
This is how you can handle & in your incoming message:
http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/9420 [original link is broken] [original link is broken] [original link is broken]
Regards, Gaurav.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
For XML escape characters, they need to be encoded as specified in this link:
http://xmmssc-www.star.le.ac.uk/SAS/xmmsas_20070308_1802/doc/param/node24.html
Now, there are two approaches to your problem:
1. Request to the sending system that they encode the escape characters
or
2. You use Java Mapping to find/replace these characters so that the XML gets displayed correctly in IE.
Hope this helps,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.