SAP PI - Deciphering apostrophes in XML.
Link to Content's target Space :
SAP PI 7.1/7.0.
This article explains how to handle special characters in file based scenarios using simple mapping programs
Company: Deloitte Consulting
Created on: September 2, 2011
Sreehari, currently working with Deloitte Consulting, is a certified SAP PI consultant with sound ABAP knowledge
This interface is an ABAP proxy to XML file scenario. The XML file was generated and sent to the legacy system. However, the file failed initial validations. Reason - the field EventCode in the target contained unwanted characters (') which the legacy system could not interpret
In the first look, everything looked good in PI. The XML, post mapping step had no junk characters. Similarly, the XML file viewed using Internet Explorer also had correct data.
Lord Google told us that ''' is nothing but "XML Representation of apostrophes"
This prompted us to take a look at the XML in raw format. And there we got hold of the culprit - XML parsing.
The XML parsing that happens during graphical mapping converted the apostrophe into '''. So the obvious solution was to avoid the parsing.
This was achieved by a java mapping which transferred the the source XML as a stream to the target and while doing so, replacing the "&asos;" back to normal aposotrophe.The Java Mapping was called after the first (graphical mapping) which had the transformation rules as per business.
Note: Similar approach could be used for other XML characters as well. The XML file when viewed in Internet Explorer or the Graphical Mapping output, will display Apostrophes correctly. Only when you view the XML file as a raw text, these special characters are displayed as per XML standards