RAISE EVENT evt.
... EXPORTING p1 = f1 ... pn = fn
Triggers an event in ABAP Objects, the object-oriented extension of the ABAP language.
You can use this statement only within a method implementation (see
Method) in the implementation part of a class
(see CLASS) zulässig.
The event evt must be a component of the class.
The RAISE EVENT evt statement triggers the event
handler methods (see METHODS
and CLASS-METHODS)
that were registered for the SET HANDLER statement for this event.
After the RAISE EVENT statement, all the registered handler
methods are executed before the next statement is processed ( synchronous event handling). If a handler
method itself triggers an event, its handler methods are executed before the original handler method
continues. A handler method can call its own trigger and other handlers can be registered with the
SET HANDLER statement for the same event, which can lead
to endless recursion. To avoid this, nesting of RAISE EVENT statements is limited to 64 levels at present.
Registered handlers are executed in the same order as they are registered. A handler table (invisible
to the user is created for each instance to be triggered and for each event for which a handler method
has been registered. This handler table contains the names of the handler methods and references to
the registered instances. Each entry in the table is administered dynamically using only the
SET HANDLER statement. Each registration appends a line to
the handler table. If a registration is reset, the relevant line is removed from the table. Wenn an
event is triggered, the system reads the relevant handler table and runs the method thus called. Since
the registration is dynamic, you should not write the program in this sequence for synchronous event
handling. Instead, assume all handlers are executed simultaneously and that a handler method cannot be sure that a different handler method has been called before it.
... EXPORTING p1 = f1 ... pn = fn
This addition allows the RAISE EVENT statement topass
the actual parameters f1 ... fn to the formal parameters
p1... pn of the event evt.
In this declaration, the event interface is defined using the
EVENTS or CLASS-EVENTS
statement. In the
EXPORTING list of the RAISE
EVENT statement, you must pass every interface parameter that is declared in the interface
definition (unless it is flagged as optional). An event handler method need not however handle every actual parameter.
When an instance event is triggered the RAISE EVENT statement
automatically passes the self-reference ME to the implicit
formal parameter SENDER. This parameter must not be passed
explicitly as an actual parameter. The type of the reference variable SENDER
refers to exactly the class or interface cif listed in
the definition of the handler method using the statement METHODS ... FOR EVENT OF.
CLASS C1 DEFINITION.
PUBLIC SECTION.
METHODS M1.
EVENTS
E EXPORTING VALUE(PAR1) TYPE I
VALUE(PAR2) TYPE I OPTIONAL
VALUE(PAR3) TYPE I DEFAULT 3.
ENDCLASS.
CLASS C2 DEFINITION.
PUBLIC SECTION.
METHODS M2 FOR EVENT E OF C1 IMPORTING SENDER PAR3.
ENDCLASS.
TYPES: T_C1 TYPE REF TO C1,
T_C2 TYPE REF TO
C2.
DATA: O1 TYPE T_C1,
O2 TYPE T_C2.
CREATE
OBJECT: O1,
O2.
SET HANDLER O2->M2 FOR O1.
CLASS C1 IMPLEMENTATION.
METHOD M1.
...
RAISE EVENT E EXPORTING PAR1 = 1.
...
ENDMETHOD.
ENDCLASS.
CLASS C2 IMPLEMENTATION.
METHOD M2.
...
ENDMETHOD.
ENDCLASS.
Non-Catchable Exceptions
Special variants of other keywords
Triggering and Handling Events