CATCH SYSTEM-EXCEPTIONS

Short Reference

Syntax

CATCH SYSTEM-EXCEPTIONS [exc1 = n1 exc2 = n2 ...]
                        [OTHERS = n_others].

  [statement_block]
ENDCATCH.

Effect

The statement CATCH SYSTEM-EXCEPTIONS introduces a control structure containing a statement block statement_block that is always processed. In the list exc1 = n1 exc2 = n2 ..., you can execute catchable runtime errors and exception groups in any order. The numberic literal n1 n2 ... must be assigned to each of them. .

The OTHERS addition can be executed independently or after the list exc1 = n1 exc2 = n2 .... Its effect is the same as the specification of an exception group that includes all catchable runtime errors of the runtime environment.

The system treats the CATCH control structure as follows:

A CATCH control structure cannot be defined in the same processing block, in which the class-based exceptions are handled in a TRY control structure or are triggered by the statement. RAISE EXCEPTION.

Notes

Example

Catching all possible catchable runtime errors in a statement block. Catchable runtime errors of the exception group ARITHMETIC_ERRORS set sy-subrc to 4, all other catchable runtime errors set sy-subrc to 8. The division by 0 causes the catchable runtime error COMPUTE_INT_ZERODIVIDE, which is contained in the exception group ARITHMETIC_ERRORS. In this case, sy-subrc is also set to 4.

DATA: result TYPE i,
      number TYPE i.

CATCH SYSTEM-EXCEPTIONS arithmetic_errors = 4
                        OTHERS = 8.
  ...
  result = 1 / number.
  ...
ENDCATCH.

IF sy-subrc <> 0.
  ...
ENDIF.