on 12-14-2006 2:52 AM
Hi buddy,
I use jco to communicate with backend, an abap function module will raise a exception. I can catch that exception,
The example exception is:
<b>Exception</b> <b>Short text</b>
Test This is exception test.
e.getKey()
will return TEST.
Does any know how to get that short text "This is exception test." from the exception I caught?
Thanks
Austin
Hi Austin,
There are 2 methods to raise errors in function modules.
1) Using the raise Exception statement
2) Using a return structure like BAPIRET to populate the message details like type, error number, error text etc.
Generally method 1 is not recommended for any RFC/BAPI function modules because it causes the calling program to crash if the function raises an exception. Method 2 is the recommended way and is used in all standard BAPI's. ABAP programmers are advised to code RFC's as per method 2, but some times it would not be possible as the function would already be used and could be barred from changes.
But whatever method the RFC uses to raise an exception, web dynpro can handle it in the following ways,
Method 1) If the RFC raises an exception using RAISE EXCEPTION,
Dont catch Exception class in your code, instead do the following,
catch (WDDynamicRFCExecuteException e) {
wdComponentAPI.getMessageManager().reportException(
e.getLocalizedMessage(),
true);
Method 2) If the function returns the errors in the standard bapi return structure, you can do the following
IWDMessageManager MsgMgr = wdComponentAPI.getMessageManager();
for (int i = 0; i < ReturnNode.size(); i++) {
if (Types.indexOf("S") != -1
&& ReturnNode.getElementAt(i).getAttributeAsText("Type").equals(
"S"))
MsgMgr.reportSuccess(
ReturnNode.getElementAt(i).getAttributeAsText("Message"));
if (Types.indexOf("W") != -1
&& ReturnNode.getElementAt(i).getAttributeAsText("Type").equals(
"W"))
MsgMgr.reportWarning(
ReturnNode.getElementAt(i).getAttributeAsText("Message"));
if (Types.indexOf("E") != -1
&& ReturnNode.getElementAt(i).getAttributeAsText("Type").equals(
"E"))
MsgMgr.reportWarning(
ReturnNode.getElementAt(i).getAttributeAsText("Message"));
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
It is returning from the BAPI.
Then it has one field status u can utilize in After executing
U can capture the field.
And check your filed based on some condition.
Get the status field is
Do u want to capture that field I will give the code and u can utilize.
Or otherwise u can go as Anil's advice.
Thanks,
Lohi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try
e.getMessage() or e.toString()
Regards, Anilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Austin,
I think you need to do more on ABAP side while raising the exception .
Check the link below
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/f2bbc8142c11d3b93a0000e8353423/frameset.htm
Regards, Anilkumar
Hi
Even i don't have any knowledge on ABAP !!!
But i've found a link explains about two diferent ways of raising exceptions in functionmodules
1. RAISE except.
2.MESSAGE.....RAISING except.
Just try with the second option.
http://help.sap.com/saphelp_nw04s/helpdata/en/9f/db98fc35c111d1829f0000e829fbfe/content.htm
Regards, ANilkumar
User | Count |
---|---|
95 | |
11 | |
11 | |
10 | |
9 | |
8 | |
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.