ABAP OOP Events: RAISE EVENT and SET HANDLER with an Example

Abhinav Khasale · 4 February 2026 · 3 min read

How events work in object-oriented ABAP: declare an event, raise it, write a handler method and register it with SET HANDLER, with a complete example you can run.

Events let one object announce that something happened without knowing who will react. In ABAP, a class raises an event, other objects register handler methods for it, and the runtime calls every registered handler. You use this pattern in every interactive ALV report, and it keeps your own classes loosely coupled.

The four parts of an event

• Declare the event in the class: EVENTS for an instance event, CLASS-EVENTS for a static one. An event can have only EXPORTING parameters, passed by value.

• Raise it in a method of that class, the triggering method, with RAISE EVENT .

• Write a handler method declared FOR EVENT ... OF the class. It can import the event's parameters and, for an instance event, sender : a reference to the object that raised it.

• Register the handler at runtime with SET HANDLER . Without registration, raising the event does nothing.

Example: an order that warns above a limit

REPORT zdemo_order_events.

CLASS lcl_order DEFINITION.

PUBLIC SECTION.

EVENTS limit_exceeded

EXPORTING VALUE(ev_amount) TYPE i.

METHODS set_amount IMPORTING iv_amount TYPE i.

ENDCLASS.

CLASS lcl_order IMPLEMENTATION.

METHOD set_amount.

IF iv_amount > 100000.

RAISE EVENT limit_exceeded EXPORTING ev_amount = iv_amount.

ENDIF.

ENDMETHOD.

ENDCLASS.

CLASS lcl_alert DEFINITION.

PUBLIC SECTION.

METHODS on_limit_exceeded

FOR EVENT limit_exceeded OF lcl_order

IMPORTING ev_amount.

ENDCLASS.

CLASS lcl_alert IMPLEMENTATION.

METHOD on_limit_exceeded.

MESSAGE |Order value { ev_amount } is above the limit| TYPE 'I'.

ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.

DATA(lo_order) = NEW lcl_order( ).

DATA(lo_alert) = NEW lcl_alert( ).

SET HANDLER lo_alert->on_limit_exceeded FOR lo_order.

lo_order->set_amount( 250000 ).

Run it and a popup reports the amount. Comment out the SET HANDLER line and run it again: no popup, because nobody is listening.

SET HANDLER variants

The handler's object comes first, the object that raises the event after FOR :

• SET HANDLER lo_alert->on_limit_exceeded FOR lo_order. listens to one instance.

• ... FOR ALL INSTANCES. listens to every instance, including ones created later.

• For a static event, leave out FOR .

• ... ACTIVATION abap_false. removes the registration again.

The same steps in SE24

• Events tab: add the event with level Instance or Static, and its parameters.

• Methods tab: create the handler method, open its Detail view and enter the class and event under Event handler for.

• Write RAISE EVENT in the triggering method, then register the handler with SET HANDLER in the report or class that uses it.

Where you already meet events

In a CL_SALV_TABLE report, get_event( ) returns a CL_SALV_EVENTS_TABLE object; a handler for its double_click or link_click event is how the report reacts to a click on a row. CL_GUI_ALV_GRID works the same way with events such as toolbar and user_command . In RAP, the idea returns as business events raised with RAISE ENTITY EVENT .

Key takeaways

• Declare with EVENTS or CLASS-EVENTS , raise with RAISE EVENT .

• A handler is a method declared FOR EVENT ... OF ; it can import sender .

• Nothing happens until SET HANDLER registers the handler.

• ALV double-click and toolbar handling are events you already use.

Want to write object-oriented ABAP like this with a trainer's review? See our SAP ABAP Development course .