New Exceptions and Former Concepts of Error
Handling
In the classic ABAP world, up to Release 6.10/6.20, there were different means provided for dealing with error situations:
· Old ABAP exceptions, thrown through RAISE, can be handled with the EXCEPTIONS clause in the case of method and function calls.
· Certain runtime errors can be caught if the error position is in a CATCH SYSTEM-EXCEPTIONS block.
· Messages in MESSAGE statement can also display an error.
All these old concepts are being replaced by the new, class-based exception concept. In addition, the old concepts are too varying to ensure automatic mapping onto new, class-based exceptions.
Classic exceptions cannot be caught in handlers for new, class-based exceptions, and vice versa. Each procedure can only throw old or new exceptions. If you declare new exceptions at the interface in your procedure, you must map the old exceptions that you get from called procedures onto new ones. The reverse applies in the same way – if you use an old method and enhance it with a procedure call at whose interface new, class-based exceptions are declared.
For each catchable runtime error, there is now a corresponding exception class. Here, the grouping of catchable runtime errors is supported by inheritance relationships between the relevant exception classes. There are certain rules for the coexistence between old and new class-based exceptions:
· You cannot throw old and new exceptions in a procedure. If you declare a new class-based exception in the interface, you cannot throw any old exceptions in the procedure.
· You can catch all catchable runtime errors as old runtime errors using the old syntax. If you do not do this, these are automatically mapped onto the new exceptions by the runtime environment. If you have not declared these at the interface of the respective procedure, you will get the exception CX_SY_NO_HANDLER, which contains a reference to the old exception.