Converting IDoc XML to Flat File and Vice-Versa
Converting IDoc XML to Flat File and Vice-Versa: One fine day, one of my friends(who is new to PI) came to me and asked if we can convert any Idoc xml to Idoc flat file in SAP PI. At that time, I was sure that it could be achieved by using ABAP mapping because through ABAP mapping I can access and use the Idoc metadata which is loaded in Idoc cache IDX2. However, I wasn’t sure if we have any standard way or I would say better and easy way to do it.
Therefore, I have searched if we can convert Idoc xml to Idoc Flat file or vice-versa in SAP PI without using ABAP mapping. At that time, I came across following two new standard adapter modules available from SAP PI 7.11 that we can use when we work with Idocs. It fulfils above mentioned requirement.
- IDOCXmlToFlatConvertor – Converts Idoc xml file to Idoc flat text file
- IDOCFlatToXmlConvertor – Converts Idoc flat text file to Idoc xml file
In this blog, I will explain how to use IDOCXmlToFlatConvertor adapter module and what is the pre-requisite setting needs to be done for it.
- Create a RFC destination.
- Create a JCA Connection Factory in NWA.
- Add the Parameters in the Module Configuration of receiver Adapter (here File Adapter).
Create RFC Destination from NWA:
Create the RFC destination from NWA pointing to the SAP system where Idoc metadata (structure) is available.
Go to Configuration –> Infrastructure –> Destinations
-
- Create a new destination of type RFC Destination:
Provide all the required details such as:
Step 1 | Hosting System | SAP PI SID |
Destination Name | Any self explanatory Name | |
Destination Type | RFC Destination | |
Step 2 | Target Host | Host Name/IP Address |
System No. | As per ECC system | |
System ID | As per ECC system | |
Step 3 | Authentication | Technical User |
Language | EN | |
Client | As per ECC system | |
User | User in ECC system | |
Password | Password |
Create a JCA Connection Factory in NWA:
Go to Configuration Management > Infrastructure > Application Resources.
- Choose All JCA Resources from the Show field.
- Under the Resource Name column, choose SAPJavaResourceAdapter15.
- Under Resource Details, select Dependent JCA Connection Factories and Copy & Add new JCA Connection Factory.
- Enter the JNDI Name.
- Select and set the Configuration Properties.
Provide all the required details such as:
SAPClient, User, Password, Language, Server, Port (System No.)
Create a Receiver Channel (File Receiver):
Go to Module Tab of Communication Channel.
Add Adapter module with following details:
-
- Module Name as SAP_XI_IDOC/IDOCFlatToXmlConvertor before the CallSapAdapter Module.
- Module Type as Module Type as Local Enterprise Bean.
- Enter the Module Key
Add Parameters to Module Configuration as follows:
Parameter Name | Parameter Value |
---|---|
SAPRelease | 640/700/710 |
SourceJRA | JRA created in Step 2 |
TargetDestination | RFC Destination created in Step1 |
We have executed scenario where an ORDERS05 Idoc was sent to from ECC to SAP PI. Idoc was converted to Idoc xml by Idoc adapter and sent to IE.
We have received Idoc flat file once Idoc xml is passed through File Receiver Channel that we have configured.
In the same way one can implement IDOCFlatToXmlConvertor adapter module to get Idoc xml from Idoc flat file. Following are SAP help references.
Adding IDOCXmlToFlatConvertor in the Module Processor –
https://help.sap.com/saphelp_nw73/helpdata/en/74/A45BC07E2043FB9B63295229178903/frameset.htm
https://help.sap.com/saphelp_nwpi711/helpdata/en/74/A45BC07E2043FB9B63295229178903/frameset.htm
Adding IDOCFlatToXmlConvertor in the Module Processor –
https://help.sap.com/saphelp_nw73/helpdata/en/b5/bd93642dd3410f90ebea702399fac4/content.htm
https://help.sap.com/saphelp_nwpi711/helpdata/en/b5/bd93642dd3410f90ebea702399fac4/frameset.htm
New NetWeaver Information at SAP.com
Very Helpfull