Skip to Content

File processing

Mar 09, 2017 at 07:20 PM


avatar image
Former Member

Hi Folks,

I have a requirement where i need to merge two files at the sender side and create one and send to receiver.

Could you please let me know the best way to handle this in PI..its File adapters on both the sides.

please advise.



10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Nabendu Sen Mar 10, 2017 at 12:07 AM

Hi Smith,

As you need to send xml file to Receiver, I think File construction mode "Append" would not be much helpful (if you could transform both the files into xml through separate interfaces before merging). xml declaration at the top level will create problem. Like the solution described in :

Merge multiple input files into one output file

Now you have option for ccBPM (as you are in PI 7.1) or File lookup.

ccBPM -Demonstration of ccBPM Scenario: SAP PI 7.1 : It would involve lot of effort and need to be aware of any Performance issue, but may be best possible solution.

File Lokup -File LookUP using UDF and Graphical Variable : It will involve custom coding and not recommended. So you need to consider File size and connection.

As you have one file which is "Static" and Type "CSV", you can consider below approach but this is for Lookup purpose:

Making CSV File Lookup Possible In SAP XI !!!

There is no straight forward solution, so you need to explore different options.



10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Mar 10, 2017 at 09:19 AM

Any other valuable suggestions please

10 |10000 characters needed characters left characters exceeded
Apu Das Mar 10, 2017 at 12:49 PM

Hi Smith,

You have to follow complex path to achieve this -

1) Develop one custom module which you will use in the 2nd sender communication channel to convert your excel file to xml. Basically, a module to read excel file. There are numerous good blogs. You can refer any one.

2) In 1st CC use FCC to convert your CSV file to XML.

2) Develop one ccBPM/NWDSBPM scenario as per your server. This will be a simple file merge scenario which will merge this 2 files following one correlation and push the same in the receiver CC.

Thanks and Regards,

Apu Das

10 |10000 characters needed characters left characters exceeded
Evgeniy Kolmakov Mar 10, 2017 at 01:50 PM

Hi Smith!

You could use a little bit 'tricky' approach.

1. Put template CSV file in source folder.

2. In sender adapter parameters enable Additional files parameters and set:

namePart = ".xls"=".csv" (or any other extension you use for your csv file)

optional = NO

3. Create simple script (using bash, for example) to copy your template csv to file with the name equal to your source xls and "csv" extension.

src="${1}"<br>name=$(echo $src | cut -f 1 -d '.')
cp /your/source/path/to/template/template.csv $targetname

4. Enable "Run OS command before message processing" option with your script execution command:

/full/path/to/your/script/location/ %F

where %F will be substituted by adapter with actual source file name including path.

Regards, Evgeniy.

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

thanks for the reply Evgeny.

but windows scripts doesnt support EXCEL as it is in Binary and .CSV file is in ASCII.

Can you please share the code for windows(.bat) script if you have.

with your above approach, will i be able to merge both the files?

please suggest


No, I gave you the way to get additional file as attachment. Further, in java mapping for example, you can read both the main payload and attachment and build output payload according to your requirement.

Regards, Evgeniy.