Code to help make sense of E1 errors when called via a BSSV

johndanter

johndanter

Legendary Poster
Hi folks,

I'd like to share some free java code with you guys as some have been very helpful here. I got together with my resident java geek and we came up with this.

If like me you've noticed that calling E1 BSFNs isn't the best when you get an error, I can help you :)
E1's engine by default is designed to throw an exception when your manager encounters an error back from the BSFN it called. It also handles E1 error/warning messages via E1 Message List in the java wizard, but these messages are just the glossary text of the error.
You do not get the Object, Line Id or Error Code in E1 Message List......until now :)

In the snippet of java below, I've commented out the If messages contains errors, throw the exception and replaced it with my own new 'If messages has errors' java object called RRDMSG
RRDMSG goes off to some bssvfoundation objects and helps flesh out the error message and appends the DTAI, Line ID, and OBJ plus error DESC into the message.
This makes fault finding so much easier now, as you can see the EXACT line of code that got upset :)

//PublishedBusinessService will send either warnings in the Confirm Value Object or throw a BusinessServiceException.
//If messages contains errors, throw the exception

// John Danter BSSV Error E1 Message List mods 24/07/2017
RRDMSG.handleErrorMessages(messages, context);
/*
if (messages.hasErrors()) {
//Get the string representation of all the messages.
String error = messages.getMessagesAsString();
//Throw new BusinessServiceException
throw new BusinessServiceException(error, context);
}
*/
//Exception was not thrown, so create the confirm VO from internal VO
ConfirmGetDOC01InvTransManagerVO confirmVO = new ConfirmGetDOC01InvTransManagerVO();
confirmVO.setE1MessageList(messages);
finishPublishedMethod(context, "GetDOC01InvTrans");
//return outVO, filled with return values and messages




Code for RRDMSG inside RRDUTIL
=================================================================
package oracle.e1.bssv.RRDUTIL;

import oracle.e1.bssvfoundation.base.IContext;
import oracle.e1.bssvfoundation.exception.BusinessServiceException;
import oracle.e1.bssvfoundation.util.E1Message;
import oracle.e1.bssvfoundation.util.E1MessageList;

public class RRDMSG {

public static void handleErrorMessages(E1MessageList messages, IContext context) throws BusinessServiceException{
if (messages.hasErrors()) {
//Get the string representation of all the messages.
//String error = messages.getMessagesAsString();
String error = "";
for (E1Message e1Message : messages.getE1Messages()) {
if (e1Message.getCallObjError() != null){
error += "\n" + e1Message.getCallObjError().getGlossaryText();
error += "\nD: " + e1Message.getCallObjError().getAlphaDescription() + ", ";
error += "O: " + e1Message.getCallObjError().getFileName() + ", ";
error += "E: " + e1Message.getCallObjError().getDDItem() + ", ";
error += "L: " + e1Message.getCallObjError().getLineNumber() + "\n";

}
}
//Throw new BusinessServiceException
throw new BusinessServiceException(error, context);
}
}
}
=================================================================

Any questions, just ask.
 
Back
Top