Skip to Content

Read Entire Input file data into single field to the sender message type in SAP PI 7.1

Hi PI Experts,

I have a requirement to read entire file content into the single field, then after i have to do few transformations.

I have tried few Java codes to read entire file into the string, but i am getting a below error

<SAP:Category>XIServer</SAP:Category> <SAP:Code area="RCVR_DETERMINATION">CX_RD_PLSRV</SAP:Code> <SAP:P1>Problem while determining receivers using interface mapping: Error while determining root tag of XML: BOM / charset detection failed</SAP:P1> <SAP:P2 /> <SAP:P3 /> <SAP:P4 /> I have followed below blogs and have used the below code.

package; import; import; import; import; import java.util.Map; import; import; import; import; public class PI implements StreamTransformation { public static void main(String args[]) throws Exception { } public void setParameter(Map param) { Map map = param; } public void transform(TransformationInput in, TransformationOutput out) throws StreamTransformationException { try { String source = ""; String targetxml = ""; String line = ""; InputStream ins = in.getInputPayload().getInputStream(); BufferedReader br = new BufferedReader( new InputStreamReader(ins)); while ((line = br.readLine()) != null) source += line+'\n'; br.close(); String XML_START_TAG = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:MT_Sender xmlns:ns0=\"urn:textron:apriso:Sender/\">"; String XML_END_TAG = "</ns0:MT_Sender>"; targetxml = XML_START_TAG+ "<ns0:stringinp>"+source+"</ns0:stringinp>" + XML_END_TAG; out.getOutputPayload().getOutputStream().write(targetxml.getBytes()); } catch (Exception e) { throw new StreamTransformationException(e.getMessage()); } } public void execute(InputStream arg0, OutputStream arg1) throws StreamTransformationException { // TODO Auto-generated method stub } }

Could you please check and provide me a java code which will read entire source file into a string.


Thanks in Advance.

Thank you,


error.png (21.2 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Nov 29, 2016 at 01:07 PM
    Add comment
    10|10000 characters needed characters exceeded

  • Nov 30, 2016 at 07:39 AM

    Hi Chakradhar!

    It seems that your XML result has incorrect encoding.

    I would start with using some constant structure inside your XML in java mapping just to test if message is transferred normaly. If so - problem is in your source file data. If not - your XML structure has wrong format.

    Regards, Evgeniy.

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 08, 2016 at 10:05 AM

    Hi All,

    Thank you all for your valuable suggestions.

    Issue got resolved after removing SWCV from Reciever determination.

    Thanks Manoj K, for providing solution for this issue.

    Thank you,

    Chakradhar N

    Add comment
    10|10000 characters needed characters exceeded