Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Exception Class Heirarchy

Former Member
0 Likes
1,497

Hi Experts,

     SAP implemented exception classes to capture exceptions. CX_ROOT acts as root class for all Exception Class.

     Tracking which exception can be raised by a class is easy since it is defined the definition but how about procedural language. example in case of SQL      Statement, Read table etc...

     Try.

     E.g. Select ABCD from ABCD where (dynamic clause).

     Catch <CX_????>

     Endtry.

     Is there some document which maps exception raised by non-oops part of ABAP. If not how to find which all possible exceptions can be raised.


Thanks,

Chirantan

6 REPLIES 6
Read only

alex_campbell
Contributor
0 Likes
1,271

I've found that most of the time the Documentation for a statement (F1-Help on the keyword) will tell what exceptions a statement can raise. Although I see your point, the only mention of a dynamic sql exception I see is in the example. It would be nice to have a more reliable source for this information. Also, props to you for attempting robust error handling!

TRY.
    SELECT SINGLE *
           FROM spfli
           INTO spfli_wa
           WHERE (cond_syntax).
  CATCH cx_sy_dynamic_osql_error.
    MESSAGE `Wrong WHERE condition!` TYPE 'I'.
ENDTRY.

Read only

Former Member
0 Likes
1,271

As Alex said, you could find the exception classes avaialable in the sap help (F1), as example for Open SQL:

CX_SY_OPEN_SQL_DB

CX_SY_DYNAMIC_OSQL_SEMANTICS

CX_SY_DYNAMIC_OSQL_SYNTAX

Read only

wol
Active Participant
0 Likes
1,271

Hello Chirantan,

the exceptions directly triggered from the ABAP commands are different to the OO-Exceptions and even different to the classic exceptions.

Indeed, ABAP has no less the 3 exception mechanisms...

The ones of the ABAP commands are system exceptions and behave mostly like dynamic OO exceptions, i. e. the compiler does not check them.

The only possibility to find out which ones are thrown by a specific command is the documentation or trial and error.

Regards,

Stefan

Read only

Former Member
0 Likes
1,271

Hi Stefan,

One query here..Can we say that 'Error handling' in SAP happens via CATCH SYSTEM-EXCEPTIONS and the other two are actually 'Exception Handling'?

Thanks,

Chirantan

Read only

wol
Active Participant
0 Likes
1,271

Hello Chirantan,

you could say that.

But in following there will be the question: "What is the difference between exceptions and errors?".

So I would suggest to name the tings by their names: System-Exception and Class based Exception. Btw. the third thing are classic exceptions.

Regards,

Stefan

Read only

0 Likes
1,271

Hi Chirantan,

To my knowledge,

[OLD Exception concept]

System-exception are raised by (ofcourse) system and if not caught in try.. catch block then 'runtime error' ( = dump ) occurs.

classical exceptions are something raised by 'raise exception' syntax and if the caller can handle them through 'sy-subrc'..,

Both are still 'Exceptions'!

[NEW OO Exception concept and System-exceptions]

every system-exception has now OO equivalent exception..both old and new exceptions exists in parallel!

these system-exceptions fall under category 'CX_DYNAMIC_CHECK' of OO Exceptions..

In above example given by Felipe, OO Exception CX_SY_OPEN_SQL_DB is equivalent to (old) multiple system-exceptions e.g. DBIF_RSQL_SQL_ERROR, DBIF_RSQL_INVALID_RSQL etc..

You can get the actual 'Runtime error ID' (i.e. old system-exception text) which caused the exception as a attribute 'KERNEL_ERRID' of the OO Exception (It is availble from the root exception cx_root).. i.e. mapping of system-exception to OO exception..

I hope it helps in clarification..

Best Regards,

Abhijit