on 05-31-2006 3:41 AM
Hi guys,
I occured a weird problem when web dynpro handling exception thrown by BAPI. Here is my code:
try {
wdThis.wdGetCreateCustController().execute_ZBAPI_TRIP_CHANGE_FROM_DATA();//throws an exception from BAPI
} catch (Exception e) {
if(e != null) manager.reportException("exception:" + e.toString(),false);//NullPointerException????
if(null != wdContext.nodeReturn()) {
wdContext.nodeOutput().invalidate();
int returnsize = wdContext.nodeReturn().size();
for(int i = 0;i<returnsize;i++) {
IPrivateCreateView.IReturnElement ob = wdContext.nodeReturn().getReturnElementAt(i);
String msgtype = ob.getType();
String msg = ob.getMessage();
if("S".equalsIgnoreCase(msgtype)) {
manager.reportSuccess(msg);
} else if("E".equalsIgnoreCase(msgtype)) {
manager.reportException(msg,false);
} else manager.reportWarning(msg);
}
}
}
Weird problems:
1. When an exception is thrown by the BAPI, the exception seems to be print in my message area automatically.
2. The line if(e != null) manager.reportException("exception:" + e.toString,false) will throw an NullPointerException
3. We can't get the rows in return table, which should be one row when executed in SE37.
Can anyone give me an explanation?
Best Regards,
Xiaoming Yang
Hi,
Ideally your BAPI shouldn't raise exceptions - it is much better to use the RETURN table from your BAPI with any relevant messages - have a look at the majority of standard SAP BAPI's in transaction BAPI.
This way, the only exceptions your try... catch block needs to handle are those related to the actual calling of your BAPI, not it's functionality.
Also, if you can successfully run the BAPI in SE37 but it fails when called from your WD application, try using the FBGENDAT functionality to capture what data is being passed to SAP from your Web Dynpro application. All it takes is a simple mistake in setting up your contexts or logic and you won't be calling your BAPI correctly.
Hope this helps,
Gareth.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Valery,
That's what I meant - I just wasn't very clear!
The exceptions should be coming only from the communication between WD and SAP Backend and not the actual business logic inside the BAPI. This way it is easier to trace problems and decide whether they are with the logic of your BAPI or in fact with your JCo connections or related.
Gareth.
xiaoming,
Inside catch block Exception "e" can never be null, however variable "manager" seems to be null, check this instead.
Next, do not mix exception handling and handling of BAPI return messages, this processing (BAPI returns) should be placed inside "try" block (btw, this may cause NPE as well).
Valery Silaev
EPAM Systems
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.