
Registering and Handling Events
Purpose
The SAP Toolbar can trigger events when the user either chooses a function or requests a menu. In order to process these events in your program, you must
For further information, refer to
Event Handling.
Prerequisites
Process Flow
Example
The following example registers the event
function_selected of the SAP Toolbar as a system event:DATA: event TYPE cntl_simple_event,
events TYPE cntl_simple_events.
CLASS lcl_toolbar_handler DEFINITION.
CLASS-METHODS: on_function_selected
FOR EVENT function_selected OF cl_gui_toolbar
IMPORTING fcode.
ENDCLASS.
CLASS lcl_toolbar_handler IMPLEMENTATION.
METHOD on_function_selected.
CASE fcode.
WHEN <f1>.
* Process function
WHEN <f2>.
* Process function
...
ENDCASE
ENDMETHOD.
ENDCLASS.
event-eventid = cl_gui_toolbar=>m_id_function_selected.
event-appl_event = ' '.
APPEND event TO events.
CALL METHOD toolbar->set_registered_events
EXPORTING events = events.
SET HANDLER lcl_toolbar_handler=>on_function_selected FOR toolbar.