CATCH SYSTEM-EXCEPTIONS statement in ABAP is used for catching a catchable runtime error. We can specify individual runtime errors or exception groups with this statement. This statement creates a control structure and always should end with END CATCH statement.
Syntax
CATCH SYSTEM-EXCEPTIONS [exc1 = n1 exc2 = n2 …]
[OTHERS = n_others].
[statement_block]
ENDCATCH
Numeric literals are allocated to each exception. You will get clearer picture after seeing the following sample code.
DATA: number1 TYPE i,
number2 TYPE i.
CATCH SYSTEM-EXCEPTIONS arithmetic_errors = 4
OTHERS = 10.
…
number1 = 1 / number1.
…
ENDCATCH.
IF sy-subrc <> 0.
…
ENDIF.
In this example you can see that exception are specified and assigned with numerical values in CATCH SYSTEM-EXCEPTIONS statement and also use OTHERS addition for handling all other exceptions that are not specified individually.
If any runtime error occurred which is specified in the CATCH SYSTEM-EXCEPTIONS statement, immediately execution of the statement block will be terminated and control will goes to ENDCATCH statement and program execution will continue from there. And the value assigned to that exception will be stored in the system field sy-subrc.
In this example, if the exception is arithmetic_errors then sy-subrc will contain the value 4.
If the statement block is executed completed and reached ENDCATCH statement and no runtime errors occurred, then sy-subrc will set with a value 0.
Also Read : View Other ABAP Keywords & Syntax -> ABAP Transaction codes