Other recent blogs
SAP PI/PO provides out-of-the-box functionality to handle file content conversion from Flat file to XML and vice versa in File Adapter. This function can only be used if the file isn’t encrypted. For handling File content conversion along with PGP, we need adapter modules and advanced user detail function. This blog outlines the steps to achieve this.
PGP Decryption and Flat File to XML Conversion in the Sender Channel
In the sender communication channel, we need to specify two additional adapter modules.
- Localejbs/PGPDecryption: This module is used to decrypt the PGP message. It should be the first to be used so that the file is decrypted before content conversion.
- AF_Modules/MessageTransformBean: This module is used to convert Flat file to XML message with the first line in a single segment. It should be used next so that the file is converted from Flat to the XML structure.
- CallSAPAdapter: This is the default module of the channel and must be the last module to be used.
Once the modules have been specified, create the Sender Data Type as specified in the pattern below. All the elements of the line will be stored in ‘Record,’ and multiple occurring nodes will be enabled in ‘RecordSet.’
For our requirements, we need only three fields from each line of CSV so that our receiver structure looks like below. You can change it to suit your objectives.
Moving ahead, create a Message Mapping, and define an Advanced User Defined Function (UDF).
The UDF takes the whole line as a string and splits it at each page. You can update the delimiter to whatever is used in the file.
Output 1: This delivers the second string after the split.
Output 2: This delivers the fifth string after the split.
You can change the number and position of outputs according to your needs.
Configure the mapping in the manner illustrated below.
Test this message mapping.
Create an Integrated Configuration for this scenario and activate your objects. This should decrypt the encrypted PGP message and split the elements successfully.
Handle PGP Encryption and XML to CSV Conversion in the Recruiter Channel
Create ESR and Integration Directory objects as usual, but in the Receiver File Channel instead of using File Content Conversion, use Adapter Modules in the sequence mentioned below.
- Localejbs/AF_Modules/StrictXml2PlainBean: This module is used to convert XML to CSV.
- Localejbs/PGPEncryption: This module is used to encrypt the outgoing message.
Following the above-mentioned steps, you can successfully handle File content conversion along with PGP Encryption/Decryption. These steps will work with any adapter that supports enhancement through adapter modules. Please note that while using the default File content conversion provided by PI/PO, File adapter will not work with PGP encrypted messages.