Create multiple files from single file based on data.
Create multiple files from single file based on data.
While working in one scenario, I got a requirement where the source data consists of multiple records for multiple PARTNERS. At the target side, we have to generate multiple files, one for each partner.
I feel many of us would have faced similar requirement. In this document, I am sharing the way I implemented it.
The source data looks similar to the one shown below.
Source File.
Employee; Subject: Marks EMP1;MATHS;23 EMP2;ENGLISH;45 EMP1;PHISICS;33 EMP1;ENGLISH;39 EMP2;PHISICS;37 |
There could be N number of EMPloyees
The target should look like this.
Target File: 1
Employee; Subject: Marks EMP1;MATHS;23 EMP1;PHISICS;33 EMP1;ENGLISH;39 |
Target File 2
Employee; Subject: Marks EMP2;ENGLISH;45 EMP2;PHISICS;37 |
One way to do this is, for N different EMPLOYEES, create N nodes at the target side in multimapping. This approach is lengthy, and could not be used if we don’t know exact number of Employees. Here, I will be using one Message at the target side, to create multiple files based on Employees.
Sender/ receiver Data type.
Sender and receiver structure will be same.
In Message Mapping, we have to change the occurrence of Target message to 1 to Unbounded. This can be achieved from Signature tab in message mapping.
The sender data will be as shown in screenshot below.
Sender Data
Expected output data:
Here, every “FetchData_1” node will generate separate file at the target side.
Mapping for “FetchData_1” node.
EMPName is raised to context of FetchData_1. Similar mapping will be done for Records.
For other items eg: Subject field below mapping needs to be done.
Context for EMPName and Subject is raised to FetchData_1 node.
Here EMPName is used for mapping all other fields because we have to create different files based on EMPNumber.
Please share your views on this. Please let me know if there is any possibility of improvement in this design.
Hi Gavaksh,
Good document 🙂