ABAP Keyword Documentation →  ABAP − Reference →  Program Flow Logic →  Exception Handling →  Class-Based Exceptions → 

RAISE EXCEPTION  Syntax Diagram

Short Reference

Syntax

RAISE [RESUMABLE] EXCEPTION
  { {TYPE cx_class [EXPORTING p1 = a1 p2 = a2 ...]}

  | oref }.

Addition:

... RESUMABLE

Effect

This statement interrupts execution of the current statement block and raises a class-based exception. It can be used at any point in a processing block. The statement interrupts the program flow and searches for a handler as described in System Response After a Class-Based Exception. Depending on the definition of the handler, the context of the exception is closed before or after the handler is executed; this can include cleanup tasks. Only if the RESUMABLE addition is declared can processing be resumed again after the RAISE EXCEPTION statement during handling, without closing the context.

If the TYPE addition is specified, an exception of exception class cx_class is raised and, if necessary, an exception object is created. Every exception class cx_class visible at this point can be specified after TYPE. The EXPORTING addition can be used to assign appropriate actual parameters to the input parameters of the instance constructor of the exception class by using the same syntax as used for CREATE OBJECT. As in regular method calls, a1, a2, ... are general expression positions. In other words, functions and expressions can be passed as actual parameters, alongside data objects. Special rules apply in this case.

If oref is specified, no new exception object is created when the exception is raised. For oref, an object reference variable must be specified that references an existing exception object. In the existing exception object, the internal attributes that describe the position of the exception and that are read using the method GET_SOURCE_POSITION, are applied at the position of the RAISE statement. In addition, the attribute IS_RESUMABLE is set to a new value, depending on how the addition RESUMABLE is used.

The RAISE EXCEPTION statement must not be used in a method or function module in whose interface non-class-based exceptions are declared. Also, the statement does not permit simultaneous use of the CATCHSYSTEM-EXCEPTIONS statement for the obsolete handling of catchable runtime errors, and the RAISE or MESSAGE RAISING statements to raise non-class-based exceptions in function modules and methods in the current processing block.

Notes

Example

See Exceptions, RAISE.

Example

A predefined exception is raised explicitly for which an exception text other than the standard exception text is selected and whose placeholder &TOKEN& is filled by passing a value to the attribute with the same name.

DATA exc  TYPE REF TO cx_sy_dynamic_osql_semantics.

TRY.
    ...
    RAISE EXCEPTION TYPE cx_sy_dynamic_osql_semantics
      EXPORTING textid = cx_sy_dynamic_osql_semantics=>unknown_table_name
                token  = 'Test'.
    ...
  CATCH cx_sy_dynamic_osql_semantics INTO exc.
    MESSAGE exc->get_text( ) TYPE 'I'.
ENDTRY.

Addition

... RESUMABLE

Effect

The RESUMABLE addition raises an exception as a resumable exception. When an exception of this type is handled in a CATCH block, the RESUME statement can be used to jump back to directly before the raising statement, as long as the context of the exception was not deleted before the exception was handled.

Notes