cancel
Showing results for 
Search instead for 
Did you mean: 

Can we combine multiple XMLs into single xml using append option in receiver channel in SAP PI 7.4

krishnavamsikola
Explorer
0 Kudos
1,360

Is it possible to create a Pass through scenario where sender channel picks multiple XMLs of different structure from a directory and combine using append command in receiver channel to form single xml and place in target path

View Entire Topic
peter_wallner2
Active Contributor
0 Kudos

Hello,

look at this: https://blogs.sap.com/2014/06/06/merge-multiple-files-without-bpm/

I followed that blog a few months ago and it works well. The only downside: the actual sender channel that does the combining must be of NFS. So I am pulling 2 files from an SFTP and save them on a folder on our PO system. The next scenario then picks the files from there with an NFS (File) Sender channel and the OM has the java map as the first mapping step and combines the two XMLs.

Good luck, Peter

krishnavamsikola
Explorer
0 Kudos

Hi Peter, firstly thanks for the suggestion, can we use this technique to merge more than 2 files.

peter_wallner2
Active Contributor
0 Kudos

Hello Vamsi, I don't know. I only tried it with 2 files, like it is done in the blog. I would give it a try.

0 Kudos

Hi Peter, I’m following that blog from Arpil for the same requirement but i’m getting a NullPointerException; while trying to invoke the method org.w3c.dom.Node.getNodeType() of a null object loaded from local variable source. Can you let me know how your files look like? The channel was able to pick up the file and the attachments.

peter_wallner2
Active Contributor
0 Kudos

Hello Gal Leeloo,

there is one line in the java mapping:

Element element = (Element) attachmentDoc.getElementsByTagName("Recordset2").item(0);

that basically "grabs" the attachment XML by using the root elment name. In my example that root is called "Recordset2". Make sure you adapt that in the java map to that element name. If not, I could imaging you get a null pointer because it tries to get an element by tag name and does not find any.