Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Declarations →  Declaration Statements →  Classes and Interfaces →  Components in Classes and Interfaces →  Events 

EVENTS

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


EVENTS evt [EXPORTING parameters]. 

Addition

... EXPORTING parameters

Effect

Declares an instance event evt in a class or interface. The Naming conventions apply to the name evt. Using the RAISE EVENT statement, the instance event evt can be raised in any instance method of the same class, or of any class that implements the interface, as well as in the instance methods of subclasses - if they are visible there.

Addition

... EXPORTING parameters

Effect

The EXPORTING addition defines the parameter interface of the event evt. An event can only have output parameters parameters that are passed by value.

When you declare an event handler with the addition FOR EVENT OF of a METHODSor CLASS-METHODS statement, the output parameters of the event are defined as the input parameters of the event handler. The properties of the input parameters are copied across from the output parameters defined in EVENTS.

As well as the output parameters defined explicitly using EXPORTING, each instance event has an implicit output parameter, sender. This output parameter has the type reference variable. When the event is raised using RAISE EVENT, the reference to the raising object is implicitly assigned to sender.

The static type of the input parameter sender is defined for every event handler by the object type (class or interface) that is specifed after the FOR EVENT OF of theMETHODS or CLASS-METHODS statement.


Note

The dynamic type of the implicit formal parameter sender is always the class of the object in which the event is raised.


Example

In the interface window, three events are declared, each with an explicit non-optional output parameter status. The class dialog_window implements the interface window. The interface window_handler contains event handlers, which import both the explicit parameters and the implicit parameter sender. The static type of the input parameter sender is the class dialog_window.

INTERFACE window. 
  EVENTS: minimize EXPORTING VALUE(status) TYPE i, 
          maximize EXPORTING VALUE(status) TYPE i, 
          restore  EXPORTING VALUE(status) TYPE i. 
ENDINTERFACE. 

CLASS dialog_window DEFINITION. 
  PUBLIC SECTION. 
    INTERFACES window. 
ENDCLASS. 

INTERFACE window_handler. 
  METHODS: minimize_window 
            FOR EVENT window~minimize OF dialog_window 
             IMPORTING status sender, 
           maximize_window 
             FOR EVENT window~maximize OF dialog_window 
             IMPORTING status sender, 
           restore 
             FOR EVENT window~restore OF dialog_window 
             IMPORTING status sender. 
ENDINTERFACE.