on 04-18-2014 11:17 AM
Dear Friends,
I am using Sender JDBC Adapter and Receiver File Adapter in Integration Flow in SAP PI 7.3 EHP 1 SP08 Java Stack environment. The requirement is that we need to create multiple files based on the row count in jdbc resultset. If there are 5 rows in resultset, we need to create 5 XML files with one row elements in one file. Similarly if there are 10 rows, we need to create 10 XML files.
So how can we create multiple files in this scenario. I tried placing a for loop in the Java Mapping as below in the transform method:
DynamicConfiguration conf = arg0.getDynamicConfiguration();
StringBuffer sbFileData = new StringBuffer();
for (int i =0; i < record.size(); i++ {
.
.
. // Create XML for each row and Marshal the object into to the String Buffer
String strFileName = "DC_" + new SimpleDateFormat("ddMMyyyyHHmm").format(new java.util.Date())+"_"+i+".xml";
conf.put(KEY_FILENAME, strFileName);
arg1.getOutputPayload().getOutputStream().write(sbFileData.toString().getBytes("UTF-8"));
arg1.getOutputPayload().getOutputStream().flush();
}
So here I'm flushing the OutputStream for each record. But it's not creating the multiple file, instead it creates only one file will all record XMLs appended to each other.
Please let me know if I missing something or need to do some thing else.
Regards,
Shreyansh Shah
Hi,
you have to use multi mapping for this. hope this can help you.
Multi-Mapping using Java Mapping - Process Integration - SCN Wiki
Any reason why you are going for java mapping?
you can handle this in message mapping also.
Regards,
Muni.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
You can easily achieve this using graphical mapping. Create your target message type like below
MT_Target
Details 0 to 1
Data 0 to 1
Source sample structure
<resultset>
<row>
<column-name>column-value</ column-name>
</row>
Then do the message mapping like below
map <row> with MT_Target
contant ----> Deatils
column-name ------>Data
In the signature tab of message mapping, choose the occurrence of your target message type as
0 to unbounded.
This will generate multiple files from multiple rows.
Let me know if you have any doubt.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.