You are on page 1of 7

OOABAP EVENTS

Events In OOABAP
 Events are the message raised by an object. Whenever any condition is met, object can raise an event. E.g. Timer has
expired, Cut-off Limit has reached, User Interaction happened etc. This event than can be caught by the receiver. The
receiver than implements the logic to handle the event. E.g. When Timer has expired, render the page again; When cut-
off limit is reached, tell user to stop etc.
 The objects designer doesn’t need to know who would handle the event or not. But it gives an opportunity for any
receiver object to catch and process. Its kind of taking a roll call at few intervals in the discussion if anyone of the line
has any question. If anyone has the question, they can ask at that time. The receiver object generally doesn’t care how the
event was raised. For receiver, it only matters the fact that event was raised and its now trapped in its event handler.

Steps to create events in OOABAP


 Defining The Events
 Raise Event
 Handling The Events
 Registering The Handlers Of Event
Defining The Events
To define the event, you need to give a meaningful name. You can also declare parameters for the event which can be
used to expose the data for the receiver.

Syntax: EVENTS: Event_name.


Raise Event
Raising an event can be done via RAISE EVENT
Syntax: RAISE EVENT Event_Name.
Handling The Events
First of all you would need to create a receiver object. So, when you declare the method in the receiver
class, you define that the method is handler method using FOR EVENT.

Syntax: METHOD Method_name For Event Event_Name of Class_name Importing value.


Registering The Handlers Of Event
If some receiver wants to handle the event, it would need to let the system know about its intension.
In ABAP, you can do it via SET HANDLER

Syntax: SET HANDLER Event_Object_name->Method_name For Main_object_name


Registering The Handlers Of Event
If some receiver wants to handle the event, it would need to let the system know about its intension.
In ABAP, you can do it via SET HANDLER

Syntax: SET HANDLER Event_Object_name->Method_name For Main_object_name

You might also like