on 04-09-2015 11:09 AM
Hi PI Experts,
I am working on Receiver FCC, where i need to place a target file in an Unix server.
By default target file will get LF(line feeder) at the end of each line, but my requirement is not to populate LF for the last line.
Please find the below screen shot of sample target file
I have tried giving below shell commands in processing tab of communication channel
4. sed '${/^$/d;}' file.txt
3. sed '/^\s*$/d' file.txt
but it is not working.
Please help me out.
Thanks in advance.
Thank you,
Chakradhar N
Chakradhar,
1. Use StrictXml2PlainBean or MTB (remove FCC) in receiver channel.
2. After above module, add below custom adapter module to remove last byte (last new line character).
package com.test;
import java.util.Arrays;
import com.sap.aii.af.lib.mp.module.*;
import com.sap.engine.interfaces.messaging.api.*;
public class RemoveLastByte implements Module {
@Override
public ModuleData process(ModuleContext mc, ModuleData md) throws ModuleException {
try {
Message msg = (Message) md.getPrincipalData();
Payload pay = msg.getMainPayload();
java.io.InputStream in = pay.getInputStream();
byte[] b = new byte[in.available()];
in.read(b);
// Remove last byte and write it to output.
pay.setContent(Arrays.copyOf(b, b.length - 1));
md.setPrincipalData(msg);
} catch (Exception e) {
throw new ModuleException(e);
}
return md;
}
}
I have not tested above code (please use it as guide).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mistri,
Thanks for quick reply
I have tried giving below for end separator but i am getting all the lines in a single line.
end separator = 0x0D (Carriage return)
end separator = 0x0A (NL line feed, new lineà)
end separator = '' (null)
Also, i have checked below links and found that we don't have a conversion parameter to remove LF from the file. I hope we have to do it by shell command/script.
http://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=40772
http://scn.sap.com/thread/1540983
Thank you,
Chakradhar N
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
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.