Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Calling and leaving program units →  Calling Processing Blocks →  Call Event Handler →  SET HANDLER 

SET HANDLER - FOR

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


SET HANDLER handler1 handler2 ... FOR { oref |{ALL INSTANCES} } 
                                 [ACTIVATION act].

Extras

1. ... FOR oref

2. ... FOR ALL INSTANCES
3. ... ACTIVATION act

Effect

This statement registers the event handlers handler1 handler2 ... for the corresponding instance events of the objects specified after FOR. An event handler is executed if the corresponding instance event is triggered with RAISE EVENT in an object for which it is registered. Using the ACTIVATION addition, event handlers can be deregistered or a dynamic registration can be executed.

An event handler handler can be specified as follows, where the indicators have the same meaning as in CALL METHOD:

  • meth
  • oref->meth
  • class=>meth

You can specify methods meth of the same or other classes that are defined as instance event handlers with the FOR EVENT evt OF {class|intf} addition to the the statments [CLASS-] METHODS. You cannot specify event handlers for static events. You must specify at least one indicator.

The type class or intf specified after FOR EVENT OF in the definition of an instance event handler specifies the objects whose events it can handle. You can use the FOR addition to specify single objects or all objects that can be handled.

Addition 1

... FOR oref

Effect

This addition registers the event handlers of the list handler1 handler2 ... for exactly one object. Here, oref is an object reference that must point to an object whose events can be handled by the specified event handlers. The class of the object must be class or the subclass of class, or must implement the interface intf directly or via a superclass.

Addition 2

... FOR ALL INSTANCES

Effect

This addition registers the event handlers of the list handler1 handler2 ... for all objects whose events it can handle. These are all objects whose classes are either class or the subclass of class, or which implement the interface intf directly or via a superclass. This registration is also valid for all triggering instances that are created after the statement SET HANDLER.

Addition 3

... ACTIVATION act

Effect

You can specify a single-character text-type field act after the ACTIVATION addition. If act has a value "X", the event handlers handler are registered; however, if act has the value " ", the registration of the event handlers handler is cancelled. You cannot deregister a single registration via mass deregistration. Vice versa, you cannot cancel registration of individual triggering objects after a mass registration.


Note

As long as the registering of an instance method as an event handler is not cancelled using ACTIVATION " ", the relevant object cannot be deleted from the garbage collector, since it is still being used by the runtime environment.