on 11-05-2014 9:43 PM
Hi
We are getting sometimes various specail characters in payload coming from idoc as source in different fields . Is there anyway we can remove these special characters in payload without applying to individual field
Thanks
Mahesh
Hi Mahesh,
use a java mapping to remove special characters. below code will replace all the special characters you provide in the check string array with a null value.
public class REPLACESC implements StreamTransformation {
private AbstractTrace trace = null;
private Map param = null;
String inputFileName;
public void setParameter(Map param) {
this.param = param;
if (param == null) {
this.param = new HashMap();
}
}
public void execute(InputStream in, OutputStream out)
throws StreamTransformationException {
trace = (AbstractTrace) param.get(StreamTransformationConstants.MAPPING_TRACE);
trace.addWarning("JAVA Mapping Start");
/*this block of code will remove all the not allowed special characters from outbound xml*/
try
{
byte b[]=new byte[in.available()];
String encoding="UTF-8";
in.read(b);
String inputXML=new String(b);
String[] check = { "]", "&", "<", ">", """, ",", "#", "\\$", "@", "\\[", "\\)"};
for (int i = 0; i < check.length; i++) {
inputXML=inputXML.replaceAll(check[i],"");
}
out.write(inputXML.getBytes(encoding));
}
catch(Exception e)
{
throw new StreamTransformationException(e.getCause().toString());
}
}
public void transform(TransformationInput arg0, TransformationOutput arg1)
throws StreamTransformationException {
this.execute(arg0.getInputPayload().getInputStream(), arg1.getOutputPayload().getOutputStream());
}
}
you can also use an excel file to store special characters and do a file lookup if the number of special characters are not fixed. let me know if you want to use this option , i will share the code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank u. The no of special characters are not fixed. We are getting the data with the specail characters as below in different fields coming from idoc as source and receiver side SOAP .Where should I apply udf ?
879234530�A.ï
849031B?Â
9453070� kaON
1Â TVERCDSAÂ AVEÂ BLDGÂ 47599
1040Â NOUTHÂ KITAÂ RD
537879020Ã?Â
Thank for your help
Hello,
I can see some french characters like Â, so are u sure u really want to delete these characters from ur data?
Technically speaking ur receiver should accept the data in the format which is coming from SAP becuase if u delete these special characters then u are actully truncating the values which is not right?
Thanks
Amit Srivastava
The above code I shared will check the whole Idoc for special characters you hard coded and replace it with null value.
This is not a udf, you have to create a java map using imported archive and apply it in operation mapping before message mapping...follow the link shared by Hareesh above on how to create a java map.
Let me know if you have any questions!!
Thanks
Navneet.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Nabendu for mentioning me in the thread.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.