Entering content frame

Events: Overview Graphic Locate the document in its SAP Library structure

Suppose we have two classes, C1 and C2:

This graphic is explained in the accompanying text

The class C1 contains an event E1, which is triggered by the method M1. Class C2 contains a method M2, which can handle event E1 of class C1.

The following diagram illustrates handler registration:

This graphic is explained in the accompanying text

The program creates an instance of the class C1 and two instances of the class C2. The values of the reference variables R1, H1, and H2 point to these instances.

The SET HANDLER statement creates a handler table, invisible to the user, for each event for which a handler method has been registered.

The handler table contains the names of the handler methods and references to the registered instances. The entries in the table are administered dynamically by the SET HANDLERstatement. A reference to an instance in a handler table is like a reference in a reference variable. In other words, it counts as a use of the instance, and therefore directly affects its lifetime. In the above diagram, this means that the instances C2<1> and C2<2> are not deleted by the garbage collection, even if H1 and H2 are initialized, so long as their registration is not deleted from the handler table.

For static events, the system creates an instance-independent handler table for the relevant class.

When an event is triggered, the system looks in the corresponding event table and executes the methods in the appropriate instances (or in the corresponding class for a static handler method).



Leaving content frame