File Content Conversion In Sap Pi At Receiver

File Content Conversion Scenario. Input Message: This is the input message to the receiver file adapter sent from XI. Input XML message. Output Message: Fig3. Output CSV Message. SAP PI Interview Questions and SAP PI Tutorials SAP PI Interview Questions and SAP PI Tutorials.

File
  • Receiver File content conversion has got an escape route and that is XSLT. Simple or complex, it is a matter of few lines of code in XSLT, rather than a brainstorming in FCC:).
  • If the target message (file) created by Message Mapping needs to be converted by the Receiver Adapter Communication Channel select the option ‘ File Content Conversion ‘. Usually, if the receiver file format is anything other than XML, you can use this feature to convert the file to an appropriate format such as CSV, Text, etc.
  • Vikram, if I understand correctly you are able to change input XML payload? If so, solution may be quite easy and you are on the right track. You will just need to specify two recordset structures with recordset 1 handling your 'header' and taking its values from 'Detail' node of your input XML and recordset 2 handling all the 'body' data taking values from 'firstname', 'lastname', 'city'.

XI - File Content Conversion

Developments on Integration Directory.

1.Configuration of Sender File Adapter

Here specify Message Protocol as ‘File Content Conversion’.

Document Name and Namespace correspond to the message type from the Integration Repository.

Recordset Name defines the root node under which rest of the XML will be created.

Recordset Structure defines the name and occurrence of each sub-node in Recordset Structure. In this example we have only one occurrence of sub-node Emp_Header and Emp_Summary and unbounded occurrences of sub-node Emp_Weekly_Det.

Key Field Name and Key Field Type helps in differentiating different substructures. In this case Key =1 implies Emp_Header node, Key = 2 implies Emp_Weekly_Det node and Key = 3 implies Emp_Summary node.

Additional Parameters are given below.

File Content Conversion In Sap Pi Receiver

  • <node>.fieldFixedLengths – comma-separated ordered list of field lengths in the particular node
  • <node>.endSeparator – identifies end of record
  • <node>.fieldNames – comma-separated ordered list of field names in the particular node
  • <node>.keyFieldValue – Value of the key field
  • <node>.keyFieldInStructure – ‘ignore’ (without quotes) indicates that the Key field should not be generated in the resulting XML whereas ‘add’ (without quotes) indicates that it should be added.

2.Configure Receiving File Adapter

3.Configure Receiver Agreement

4. Configure Sender Agreement.

Sap Pi Sheet

5.Configure Interface Determination.

6.Configure Receiver Determination.

Sap Pi Jobs

On Executing the Scenario we will get the output file in XML Format.

Recently went through a question on content conversion for receiver file adapter, where the xml contains multiple header and detail lines. The question is posted here –

Worked on this problem via XSLT which saves the pain for content conversion. Using XSLT, we can convert any xml into csv / other text formats without worrying for XML hierarchy

Structure for this example is as mentioned below –

Output from the interface should be as mentioned below

Source XML data:

one option is obviously trying via content conversion or message transformation bean which might need some tricks but knowing XSLT gives an edge here.

This requirement can be achieved via a simple XSLT mapping. The idea behind that is that just print the segments we need in the output and pass to the receiver file adapter as it is. In other words, no need to use the content conversion

File Content Conversion In Sap Pi At Receiver Configuration

Here is the XSLT, which would provide us the desired output.

File Content Conversion In Sap Pi At Receiver For Sale

Points to note:

  • I have used semicolon (;) as the field separator here. Any other separator can be used.
  • If field length is to be shortened, XPath function substring can be used to shorten the fields.
  • Similarly spaces can be added using the XPath functions by adding spaces to the fields (Field fixed length type)
  • XSLT can also be adjusted in the receiver file adapter but unit testing is as straight forward in that case as in case of XSLT mapping.

Conclusion

Receiver File content conversion has got an escape route and that is XSLT.

Simple or complex, it is a matter of few lines of code in XSLT, rather than a brainstorming in FCC :).