on 10-06-2016 9:18 AM
Hi Experts,
Receiver file channel set to produce file in UTF-8 format but sometimes producing in ANSI and not getting updated in UNIX server.
Can anyone suggest how to handle this in PI?
Thanks in Advance,
Sri Gowri
Hi Srigowri,
Regards,
Praveen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Praveen,
In my case sender is RFC and receiver is file,earlier receiver file channel was in binary but there was request received recently to produce output file in UTF-8 .txt format so we have changed the processing parameters (by setting "File Type" as "Text" and "File encoding" as "UTF-8").
This change is producing most of the files in UTF-8 format and few of them in ANSI format when validated through "UltraEdit" on Windows and not getting updated on UNIX server.
Can you suggest if anything can be done from PI end ?
Thanks,
Sri Gowri
Hi Srigowri,
As i said before receiver channel expects the payload in UTF-8 format only. it will not take any other format and change it to UTF-8.
In your case you need to use java mapping after the message mapping to convert the encoding to UTF-8 which is mentioned in below blog.
package com.map;
import com.sap.aii.mapping.api.*;
import java.io.*;
public class ChangeEncoding_JavaMapping extends AbstractTransformation {
@Override
public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException {
try {
InputStream inputStream = transformationInput.getInputPayload().getInputStream();
OutputStream outputStream = transformationOutput.getOutputPayload().getOutputStream();
//Read input as cp1252 and write output as UTF-8.
byte[] b = new byte[inputStream.available()];
inputStream.read(b);
String inS = new String(b, "Cp1252");
outputStream.write(inS.getBytes("UTF-8"));
} catch (Exception ex) {
getTrace().addDebugMessage(ex.getMessage());
throw new StreamTransformationException(ex.toString());
}
}
}
Regards,
Praveen.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.