Skip to Content
avatar image
Former Member

how to get short text of a exception thrown by abap rfc

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Dec 14, 2006 at 02:53 AM

    Try

    e.getMessage() or e.toString()

    Regards, Anilkumar

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 14, 2006 at 02:57 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 14, 2006 at 06:40 AM

    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"));

    }

    Add comment
    10|10000 characters needed characters exceeded