on 07-14-2009 11:14 AM
Hi all
I have been trying to implement a J2EE adapter engine module for XML-to-Excel conversion using the JExcel api without success. I have been using various resource that I've found on SDN to create the module. Nevertheless, PI appears to be ignoring what is in the module even though message monitor tells me that it has been processed successfully. I am fairly new at Java, so maybe somebody can help.
This is my Java code example where I am currently ignoring the content of the payload, and just want to create an Excel output file with a header row:
public ModuleData process(ModuleContext moduleContext,
ModuleData inputModuleData)
throws ModuleException {
Object obj = null;
Message msg = null;
OutputStream outStream = null;
try {
obj = inputModuleData.getPrincipalData();
msg = (Message) obj;
} catch (Exception e) {
// raise exception, when an error occured
ModuleException me = new ModuleException(e);
throw me;
}
try {
XMLPayload xmlpayload = msg.getDocument();
int counter = 0;
WritableWorkbook workbook = Workbook.createWorkbook(outStream);
WritableSheet sheet = workbook.createSheet("Prices", 0);
String header[] = new String[3];
header[0] = "Product Hierarchy";
header[1] = "Item Id";
header[2] = "Item Description";
for (int i = 0; i < header.length; i++) {
Label label = new Label(i, 0, header<i>);
sheet.addCell(label);
WritableCell cell = sheet.getWritableCell(i, 0);
cell.setCellFormat(cellFormat);
}
workbook.write();
workbook.close();
byte[] byteArray = outStream.toString().getBytes();
xmlpayload.setContent(byteArray);
inputModuleData.setPrincipalData(msg);
} catch (Exception e) {
// raise exception, when an error occured
ModuleException me = new ModuleException(e);
}
return inputModuleData;
}
}
As mentioned before, message monitor tells me that the module was called successfully:
2009-07-14 04:23:54 Success MP: Entering module processor
2009-07-14 04:23:54 Success MP: Processing local module localejbs/ConvertToExcel
2009-07-14 04:23:54 Success Module Name: ConvertToExcel, Type : Local Enterprise Bean is Called
2009-07-14 04:23:54 Success MP: Processing local module localejbs/CallSapAdapter
But nothing has been done looking at the generated file. Any help or example would be appreciated.
Thank you, Daniel
Hi Daniel,
You are forgetting put the following line:
xmlpayload.setContent(byteArray);
msg.setDocument(xmlpayload);
inputModuleData.setPrincipalData(msg);
Regards
Ivan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am not well versed with custom modules but I thought of sharing some inputs
Try to add the logs where ever possible to know upto which step it has got executed.
If possible to test in NWDS test the same by adding log files
Rajesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
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.