on 02-08-2011 10:30 AM
Hi PI Gurus,
we're facing a little problem with FCC in File Receiver Adapter. Sometimes the defined fieldSeparator ("|") comes within the field content.
e.g.
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Positions xmlns:ns0="http://test.com">
<Position>
<Value1>001</Value1>
<Value2>Test|Content</Value2>
</Position>
</ns0:Positions>
So, my first thought was to replace all "|" with a litte java mapping beind the actual mapping.
But, is there any possibility to achieve this via configuration of FCC (something like fieldSeperatorSubstitution)?
Help is as always highly appreciated!
Cheers,
Matthias Kral
Hi,
You can achive this in your message mapping. No need for java mapping.
For that field you can use Replace string function available under function category "Text"
You can replace '|' with blank space.
In example below i will replace | with a hypen -.
replaceString(/ns0:Source_MT/Field1 const(value=|), const(value=-)
Regards,
Deepak.
Edited by: Deepak Shah on Feb 8, 2011 12:24 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you guys for your ideas. But I need the solution for several messages and various fields. Putting an UDF into each mapping association would be much effort.
On the other hand, a global Java Mapping as shown below will lead into an OutOfMemoryError very quick. (In my local NWDS with messages > 20 MB)
Here's my approach for Java Mapping (just for completeness):
public void execute(InputStream in, OutputStream out)
throws StreamTransformationException {
try {
String output = new String(getBytes(in)).replace('|', ' ');
out.write(output.getBytes());
} catch (IOException e) {
throw new StreamTransformationException(e.getMessage());
}
}
Hello Hareenkumar,
yes you're totally right. I ran in several OutOfMemoryError while testing the code above. The errors started with messages over 15 MB.
Here's the code, that is productive now. It replaces all Pipes "|" by Slashes "|" and really works fine and performant.
public void execute(InputStream in, OutputStream out)
throws StreamTransformationException {
try {
int totalCount = 0;
byte[] buf = new byte[40960];
int count = 0;
while (count >= 0) {
count = in.read(buf);
totalCount += count;
if (count > 0) {
for (int i=0; i<count; i++){
if (buf<i>==124){
buf<i> = 47;
}
}
out.write(buf, 0, count);
}
}
} catch (IOException e) {
throw new StreamTransformationException(e.getMessage());
}
}
Thank you all again!!!
Cheers Matthias
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use Replacestring function: replaces each occurance of a pattern of source string by third string.
Length: returns length of the string
First argument: is the input text,
Second argument: is the text needs to be replaced.
Third argument: the text to be replaced with the second argument.
Thanks,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Matthias,
Check if the field value is passed with '|', to handle this we need to replace the character from it using UDF. After this, the adapter will do the content conversion.
Thanks,
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.