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
Define Content Conversion Parameters 14. If you have selected File Content Conversion as the Message Protocol, you can convert an XML document to a text file. Select the Content Conversion tab page. More information: Converting XML in the Receiver File/FTP Adapter to Text Format. Define Variable Substitution for Target Directory/File Name. Design your Repository objects, then in your Configuration for specific receiver file adapter we will be going to use suitable Modules in the module tab of communication channel. Though it has the same functionality like File Content Conversion in the message protocol option, this document just shows you an alternative approach to that.
File Content Conversion In Sap Pi At Receiver System
Source XML data:
File Content Conversion In Sap Pi At Receiver Free
File Content Conversion In Sap Pi At Receiver Configuration
Hi Karthik, In Receiver file adapter. message protocol select the option file content conversion from teh drop down menu. After that at the end you can see the Content Conversion Parameters in that give your root name in the place of Recordset Structure. 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.
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
Here is the XSLT, which would provide us the desired output.
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.
Sap Pi 7.1
Simple or complex, it is a matter of few lines of code in XSLT, rather than a brainstorming in FCC :).