cancel
Showing results for 
Search instead for 
Did you mean: 

Receiver file channel set to produce file in UTF-8 format but sometimes producing in ANSI and not getting updated in UNIX server.

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member182412
Active Contributor
0 Kudos

Hi Srigowri,

  • If you set the file type as binary then no conversion will be applied in the channel.
  • If the target file is text file and if you receiving the UTF-8 file to receiver channel, if you want to convert to other than UTF-8 then you can mention in File Encoding parameter in the receiver channel to convert from UTF-8 to other encoding.
  • Default is UTF-8 you no need to mention in the receiver channel to convert to UTF-8.
  • Receiver channel expecting the UTF-8 encoding if the file type as text, if it is binary then whatever the encoding it receives it will write the same encoding at target side.
  • I think in your case before coming to receiver channel the payload is not UTF-8 so you need to change the encoding before reaching receiver file adapter that means you need to it in either sender adapter or mapping level.

Regards,

Praveen.

Former Member
0 Kudos

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

former_member182412
Active Contributor
0 Kudos

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.