RAISE - Raising an Exception Defined Using the EXCEPTIONS Addition

Basic form 1

RAISE except.

Effect

This statement is only used in function modules and methods.
The exception except is triggered.
If this exception is handled by the program calling the function module or method ( CALL FUNCTION and CALL METHOD ), control returns to the caller. The current value of the EXPORTING , CHANGING (and RETURNING parameters) of the function module or method are only returned from the procedure if they are defined as passed by reference (not if they are passed by value). If the exception is not handled by the caller, the program
aborts with an appropriate error message.

Example

The function module STRING_SPLIT would appear as follows (compare the example in CALL FUNCTION):

FUNCTION-POOL CSTR.
FUNCTION STRING_SPLIT.
  ...
  IF STRING NA DELIMITER.
    RAISE NOT_FOUND.
  ENDIF.
  ...
ENDFUNCTION.

The calling program could then include the following code:

PROGRAM EXAMPLE.
...
CALL FUNCTION 'STRING_SPLIT'
*    ...
     EXCEPTIONS
          NOT_FOUND = 7.
IF SY-SUBRC = 7.
  WRITE / 'There is a problem.'.
ELSE.
  ...
ENDIF.

If the exception NOT_FOUND is triggered by the RAISE statement in the function moduleSTRING_SPLIT, the system leavesthe function module and control returns to the caller. The return code, which should be queried immediately after the CALL FUNCTION statement, now has the value 7.

Exceptions

Non-Catchable Exceptions

Runtime Error:

Related

MESSAGE ... RAISING

Additional help

Creating Function Modules