on 2022 Sep 01 7:21 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi krishnavamsikola,
The requirement is not clear.
You have not clarified on how PI server will understand when to stop appending of the incoming files.
If this information is not available or not clear, I am afraid this is not possible in PI.
Regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
In principle yes, but if you append different XML files to a single file, then the result would not be a valid XML file.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
71 | |
11 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.