In an application program, the user can trigger events in a custom control. Control then returns to the application program, which can react to the events.
Typical events are, for example, double-clicking and dragging and dropping.
As already mentioned in theControl Framework Architecture section, both the Automation Controller and the ABAP Objects Control Framework administer tables of control events. These tables have to be constructed by the application program. The event table at the frontend contains control instances and events. The event table at the backend also contains the ABAP handler method registered for the events.
You construct the tables using a special ABAP Objects Control Framework method (control->set_registered_events ). When you register the event, you must specify whether the event is to be processed as a system event or as an application event.
The handler method that you defined for the event is called automatically by the system. However, you can use the method
You must set a handler method for the event in your application program using the ABAP statementSET HANDLER . You define the handler method in your program as a method of a (local) class. It is up to you whether you define the handler method as an instance method or a static method.
When an event is triggered on a custom control, the Automation Controller checks whether the event is registered in its events table. If the event is not registered, the Automation Controller ignores it. If, on the other hand, it is registered, the Automation Controller generates anOK_CODE that it then passes to the ABAP Objects Control Framework.
The registered handler method for the event is then called - either directly (for a system event) or when you call the static methodCL_GUI_CFW=>DISPATCH (for an application event). The handler method receives the event parameter sender . This contains the object reference of the control that triggered the event.
To process an application event, you must call the static methodCL_GUI_CFW=>DISPATCH within a PAI module.
You can find out whether the event was successfully passed to a handler method by querying the parameter RC of the methodCL_GUI_CFW=>DISPATCH.