Tue. Jun 2nd, 2020

Convert IDoc XML to Flat File in SAP PI

2 min read

Recently I came across to a situation where we need to convert incoming IDoc XML into Flat File and place it to a SFTP location where EDI team will pick and send data for further processing.

To convert IDoc XML into Flat File, we have one standard module –

IDOCXmlToFlatConvertor

Below are the important steps to complete this scenario –

1. First step is to create RFC destination in NWA. If you are sending IDocs from ECC system to PI, you will already have one RFC destination “XI_IDOC_DEFAULT_DESTINATION”, which will point to ECC system. Just ping it and check if it is working fine. To do this, go to – Configuration -> Infrastructure -> Destinations and search XI_IDOC_DEFAULT_DESTINATION.

NWA1

If RFC destination is not there, then we have to create RFC destination using create button and provide all parameters required with respect to ECC system.

2.Second Step is to create JCA Connection factory in NWA. To create the new JCA Connection Factory:

  • Log in to NWA, choose Configuration Management > Infrastructure > Application Resources.
  • Choose All JCA Resources from the Show field.
  • Under the Resource Name column, choose SAPJavaResourceAdapter15.

NWA2

  • Under Resource Details, select Dependent JCA Connection Factories and Copy & Add new JCA Connection Factory.
  • Enter the JNDI Name. – Here I am using JNDI name as JCAJNDI.
  • Select and set the Configuration Properties. Set it as per below snapshot and save it.

NWA33. Final step is to create communication channel to configure this module in File Adapter or SFTP adapter. I am configuring this in SFTP adapter. Below is the channel screenshot.

channel1

We are done with configuration of this module.  Run this scenario and you will get the desired output.

While testing this scenario you will come across 2 frequently occurring errors.

1. IDOC_ERROR_INITIALIZATION: Exception in record factory – This error clearly states that error is there in configuration of resource adapter. You need to go back step 2 above and check Configuration property of JNDI name you created in step 2. Also, this error come due to wrong SAPRelease value in communication channel. Cross verify this and this error will be resolved.

2. IDOC_ERROR_PARSE_FAILURE – This error states that IDoc data is not correct. So validate data to fix this issue.

Leave a Reply

Your email address will not be published. Required fields are marked *