Character Encoding Handled the right way
In our daily business we have to handle different types of data-sources and data-sinks. Most of these data-source and data-sinks are UTF-8 aware already. But what if one of these is does not provide data in UTF-8 or does not understand it at all?
The PI/PO is only handling UTF-8-Data so how is it possible within the PI to convert the Encoding of a File/Message?
In one of our current scenarios we have to handle fixed-length files, which are read from a SFTP server.
(But this guide should also be valid for other scenarios)
The configuration is simple, but not obvious since the behaviour of the MessageTransformBean is a little bit strange 😉
Here is what you have to do in the Module-Chain of your channel if you want to convert a message from a supported encoding into UTF-8.
|Number||Module Name||Type||Module Key|
|1||AF_Modules/MessageTransformBean||Local Enterprise Bean||Codepage|
|2||AF_Modules/TextCodepageConversionBean||Local Enterprise Bean||Convert|
|3||AF_Modules/MessageTransformBean||Local Enterprise Bean||Transform|
|4||localejbs/CallSapAdapter||Local Enterprise Bean||entry|
|Module Key||Parameter Name||Parameter Value|
|Transform||xml.fieldNames||ID, Bar, Baz|
The key in this configuration is to use two different instance of the MessageTransformBean. The first one only sets the codepage, and mime-type, which is then converted by the TextCodepageConversionBean. The sencond one parses the (now utf-8) text into xml.
These two steps are necessary since the class “com.sap.aii.messaging.adapter.Conversion” expects its data as utf-8 which is not right if the incomming codepage is not utf-8 but an other one.