Show TOC

Controller EventsLocate this document in the navigation structure

Use

Events and Event Handlers of Component and Custom Controllers

You can create events on the Events tab page of a component or custom controller. These events can be triggered at runtime so that they can call event handlers of other controllers.

You can create import parameters for the created events. This means that the method that triggers the event can pass a parameter to the event. These parameters can be optional or mandatory.

On the Methods tab page of the different controllers, you can then create a special event handler (see Controller Methods).

Caution

Before you can create an event handler for an event of an event handler, you have to ensure that a controller usage has been entered for the controller triggering the event on the Properties tab page of the handling controller.

If you want an event of the component controller to be handled by an event handler in the component controller belonging to the same component, the registration must be done by the application itself. To do this you can add the following piece of code to the WDDOINIT method of the component controller:

data: l_api type ref to if_wd_component.
l_api = wd_this->wd_get_api( ).
l_api->add_event_handler(
    LISTENER_NAME    = 'COMPONENTCONTROLLER'
    HANDLER_NAME     = <event handler name>
    CONTROLLER_NAME  = 'COMPONENTCONTROLLER'
    EVENT_NAME       = <event name> ).
            

Assigning an Event to the Interface of a Component

The interface controller of a component can be represented as an independent object in the ABAP Workbench, it cannot be edited as such. Events of interface controllers are therefore implemented within the corresponding component controller and assigned to the component interface using the checkbox in the Interface column.

Actions and Inbound Plugs of a View

Actions are supplements to events, which react to user input (for example when a button is pressed). They only exist in view controllers. The corresponding event handler is located within the view controller in which the event was triggered. It is created automatically on the Methods tab page when the action is created. The action itself is entered on the Actions tab page in the View Editor (see View: Components of a View Controller).

Since when a view is called using an inbound plug the optionally available corresponding event handler is always called first, the inbound plug itself can be regarded as an event. When an inbound plug is set up, an event handler is always created automatically for this inbound plug. The new event handler is added to the {Methods tab page of the View Editor and can be programmed. In this case too, event handling takes place within the view controller.

Inbound Plug of a Window

Similarly to the inbound plugs of a view, an inbound plug of a window also behaves like an event, which can be reacted to within the same controller using an event handler. When an inbound plug is created, an event handler method is also created (just like the view), which can be programmed using the Methods tab page of the window.