on 04-01-2010 11:50 PM
Hi Experts,
We have a JDBC to FILE scenario.
In SXMB_MONI, the XML structure is like this :
<row>
<F1>No</F1>
<F2>2006-05-15 00:00:00.0</F2>
<F3>Ball Screw Inspection Tool - see ECM HS-060004-ECM</F3>
</row>
In RWB, it becomes like this:
<row>
<F1>No</F1>
<F2>2006-05-15 00:00:00.0</F2>
<F3>Ball Screw Inspection Tool - see ECM HS-060004-ECM& # x 0 ;</F3>
</row>
It is a simple one to one mapping. I dont know why it adds these special characters at the end.
Please help.
Regards.
Hi Nagasatya,
Goto payload in MONI and right click on it. Goto View Source. Here you will be able to see if special characters are present in the source.
Regards,
Gautam Purohit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> I did what you guys said and found that there are these four characters at the end which are not at the source(database).
Yes, it is in the database. It is a hex zero character. A bad program added that value.
hex 0 serves in some program languages (eg. C) as string delimeter.
> How do we remove these? Can we do this using UDF? It only happens to this field. The remaining fields are fine.
You cannot do graphical mapping with this character, so you need a Java mapping to remove the hex 0 character (or the & representation & # x 0) from XML stream.
A better solution is: Find the error in the program, which creates the entries in DB and repair data in DB.
Regards
Stefan
Hey Stefan,
I consulted the database guys and it seems they are reluctant to change the data over there.
So I had to use Java Mapping and this is the code that I am using.
/*
Created on Apr 8, 2010
*
To change the template for this generated file go to
Window>Preferences>Java>Code Generation>Code and Comments
*/
package PI_HEX_MAPPING;
/**
@author pidadm
*
To change the template for this generated type comment go to
Window>Preferences>Java>Code Generation>Code and Comments
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
public class HEX_MAPPING_CLASS implements StreamTransformation {
private Map param = null;
public void setParameter (Map param) {
this.param = param;
if (param == null) {
this.param = new HashMap();
}
}
public void execute(InputStream inStream, OutputStream
outStream) throws StreamTransformationException{
try{
BufferedReader in = new BufferedReader(new
InputStreamReader(inStream));
BufferedWriter out = new BufferedWriter(new
OutputStreamWriter(outStream));
// The pattern matches control characters
Pattern p = Pattern.compile("#x0");
Matcher m = p.matcher("");
String aLine = null;
while((aLine = in.readLine()) != null) {
m.reset(aLine);
//Replaces control characters with an empty string.
String result = m.replaceAll("");
out.write(result);
out.newLine();
}
in.close();
out.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
This still throws me an error.Any help would be greatly appreciated.
Regards.
>I consulted the database guys and it seems they are reluctant to change the data over there.
>So I had to use Java Mapping and this is the code that I am using.
the problem is: how do you know in which fields this error will also occur ? Maybe also in other structures/fields which are read from this database, in other mappings ? So this isolated workaround does not make much sense. Because you do not even know that the issue is fully solved then. Maybe it will popup somewhere else again.
So better fix the problem where it originates. As PI developers we should try to reject stupid workarounds which are caused by wrong input data whereever possible. So often we can read topics here in SDN about issues which are caused by erroneous sender systems (e.g. sending invalid XML, wrong encoding, whatever). PI was not invented to fix the errors of the sender systems. If we do that in PI, we will end up with a system which is hard to maintain and understand, because we are fixing strange things from sender systems.
=> insist on correct input data in this case.
CSY
Hey guys,
Thank you very much for the help.
I resolved the issue without using mapping.
What I did was, in the sender JDBC channel, in the SQL statement, I used REPLACE function for the field causing the problem in order to remove the hex 0 character with an empty string and now it works like a charm.
Regards.
Edited by: Nagasatya Devarakonda on Apr 22, 2010 5:07 PM
Hi,
Can you download HEX software and save the message from moni and try to open in HEX and see if there are any special characters.
moni uses explorer to display XML. Ideally it should show the same thing in both.
which browser are you using to open RWB?
Regards,
Anirudh
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.