Exceptions in SAP

Exception Handling in SAP

Whenever an ABAP program is not able to handle a particular situation at runtime, it issues an Exception.

There are two types of exceptions in ABAP :

  • Handleable exceptions, which are based on predefined exception classes.
  • Non-handleable exception, which produce runtime errors directly.

Each handleable exception is associated with a runtime error.

The program terminates with this error if the exception is neither handled nor propagated to a caller.

Handleable exceptions raised by many ABAP statements can be caught by using the TRY…ENDTRY statement. You can also use the CATCH SYSTEM-EXCEPTIONS…ENDCATCH statement — but it is only possible with exception classes which are catchable. Catchable SYSTEM-EXCEPTIONS are being replaced by class-based exceptions so technically CATCH SYSTEM-EXCEPTIONS…ENDCATCH statement is considered obsolete, so its recommended you do not use them.


Unhandled exception 

The following program lines produce the runtime error COMPUTE_INT_ZERODIVIDE because division by zero is invalid and this exception situation is not handled:

DATA result TYPE i.
result = 1 / 0.


Handling exceptions using exception classes 

The above exception is represented by the exception class CX_SY_ZERODIVIDE , which is a subclass of the exception class CX_SY_ARITHMETIC_ERROR.

This means that the exception can be handled as follows (the ERR_TEXT variable is passed the text ‘Division by zero.’):






    I am returning to SAP ABAP after long long time. I am trying to understand why SAP BAPIs do not use / support exceptions?

Leave a Reply

Your email address will not be published. Required fields are marked *