2012 Oct 11 12:44 PM
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
2012 Oct 18 8:36 PM
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.
2012 Oct 22 12:33 PM
As Alex said, you could find the exception classes avaialable in the sap help (F1), as example for Open SQL:
2012 Oct 22 7:36 PM
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
2012 Nov 15 10:15 AM
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
2012 Nov 15 11:14 AM
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
2012 Nov 17 10:43 PM
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