1. RAISE except.
2. RAISE EVENT evt .
(You should only use this statement within function modules and
Triggers the exception except.
If the exception is to be handled by the caller of the function module or method (see CALL FUNCTION and CALL METHOD), the system immediately returns control to the caller. The EXPORT parameters of a function module are not filled. The EXPORTING, CHANGING and RETURNING parameters of a method are filled with their current values from the method if they were passed by reference. They are not filled if they were passed by value.
If the exception is not to be handled by the caller, the program terminates with an error message.
Suppose the function module STRING_SPLIT looked like this (see also the example for CALL FUNCTION):
FUNCTION-POOL CSTR. FUNCTION STRING_SPLIT. ... IF STRING NA DELIMITER. RAISE NOT_FOUND. ENDIF. ... ENDFUNCTION.
The calling program might then look like this:
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 of the function module STRING_SPLIT is triggered by the RAISE statement, the system stops processing the function module and returns control to the calling program. The return code, which you should evaluate directly following the CALL FUNCTION statement, now has the value 7.
... EXPORTING p1 = f1 ... pn = fn
Triggers an event in
ABAP Objects, the object-oriented extension of ABAP.
The RAISE EVENT statement can only occur in a method, which you define in the implementation part of a class using a METHOD - ENDMETHOD statement block. The event evt must be declared in the defition part of the class or in an interface implemented by the class using an EVENTS statement.
If you want a class to react to event evt, you must declare a special event handler method using METHODS meth FOR EVENT evt OF cif or CLASS-METHODS meth FOR EVENT evt OF cif. The event handler methods of individual instances or classes must be registered for the events of other objects at runtime using the SET HANDLER statement, if you want them to react to the event.
The RAISE EVENT statment passes the actual parameters f1 ... fn to the formal parameters p1 ... pn of the event evt.
The EXPORTING list of the RAISE EVENT statement must contain all of the interface parameters defined in the EVENTS statement, with the exception of those marked as optional.
However, the handling method does not have to process all of the actual parameters passed.
CLASS C_TEST1 DEFINITION. PUBLIC SECTION. METHODS M_TEST1. EVENTS E_TEST EXPORTING VALUE(PAR1) TYPE I VALUE(PAR2) TYPE I OPTIONAL VALUE(PAR3) TYPE I DEFAULT 3. ENDCLASS. CLASS C_TEST2 DEFINITION. PUBLIC SECTION. METHODS M_TEST2 FOR EVENT E_TEST OF C_TEST1 IMPORTING PAR3. ENDCLASS. TYPES: T_C_TEST1 TYPE REF TO C_TEST1, T_C_TEST2 TYPE REF TO C_TEST2. DATA: O_TEST_1 TYPE T_C_TEST1, O_TEST_2 TYPE T_C_TEST2. CREATE OBJECT: O_TEST_1, O_TEST_2. SET HANDLER O_TEST_2->M_TEST2 FOR O_TEST_1. CLASS C_TEST1 IMPLEMENTATION. METHOD M_TEST1. ... RAISE EVENT E_TEST EXPORTING PAR1 = 1. ... ENDMETHOD. ENDCLASS. CLASS C_TEST2 IMPLEMENTATION. METHOD M_TEST2. ... ENDMETHOD. ENDCLASS.