Lesson 2: Event Handling
Task
You previously added a function to your editor that allows you to load the contents of an internal table into the text window. Now, you implement a function that converts a text line into a comment line when you double-click the line.
Overview: Objectives
In this lesson, you learn how to:
-
Register events for a control that you want to catch
-
Assign events caught to event handler methods in the ABAP program
-
Write event hander methods and declare them to the control.
Basics
The event handling of controls is based on that of ABAP Objects . Generally, you use events in ABAP Objects to inform objects that a specific state has occurred.
-
The user has clicked an image.
-
The user has navigated to a new page in a Web browser.
-
The object is ready to output a table on the screen.
The following graphic shows how you can use events in your programs:

An event is a component of a class or an interface. Within the methods of the class, you can trigger defined events using RAISE EVENT .
To be able to respond to an event, you must define a method and link it to the event. It is then sufficient to trigger the event in order to handle it. These methods are also called event handler methods . By defining a second class, you can separate these methods from the object that triggers the event. This way, you can also group together handler methods of a specific type in a class.
Once the objects have been instantiated, you use the SET HANDLER statement to link the event handling method to the object in which the event is defined. The runtime environment then ensures that the method implemented is automatically called at this event.
For more information on event handling, see ABAP Objects .
To Continue
Lesson 3: Flush Optimization describes how you use flush calls and how methods are buffered before they are transferred to the frontend.