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