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,339

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
anupam_ghosh2
Active Contributor
0 Kudos

hi krishnavamsikola,

Split scenarios into two ICO.

First will be file to file with in append mode on receiver side. After sender channel stops for first ICO, then task of second ICO begins. The second ICO needs java mapping or adapter module to read the merged file produced from first scenario. Then reformats the file to create valid xml. Let me illustrate with example

These are 3 different xml files

<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
<note>
<to>Tove1</to>
<from>Jani1</from>
<heading>Reminder1</heading>
<body>hi</body>
</note>
<note>
<to>Tove2</to>
<from>Jani2</from>
<heading>Reminder2</heading>
<body>hello</body>
</note>

after first ICO merges this file it will become like this

<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
<note>
<to>Tove1</to>
<from>Jani1</from>
<heading>Reminder1</heading>
<body>hi</body>
</note>
<note>
<to>Tove2</to>
<from>Jani2</from>
<heading>Reminder2</heading>
<body>hello</body>
</note>

which is not valid xml.

In second ICO your java mapping/adapter module converts it into valid xml as shown below by adding a root node called "Email". The way you want to convert it into valid XML depends on your project requirement.

<Email>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
<note>
<to>Tove1</to>
<from>Jani1</from>
<heading>Reminder1</heading>
<body>hi</body>
</note>
<note>
<to>Tove2</to>
<from>Jani2</from>
<heading>Reminder2</heading>
<body>hello</body>
</note>
</Email>

You can consult this java code for further details on merging of XML.

This logic needs to be present in your mapping/module.

Regards

Anupam