Ansicht
Dokumentation

ABAPSET_HANDLER_INSTANCE - SET HANDLER INSTANCE

ABAPSET_HANDLER_INSTANCE - SET HANDLER INSTANCE

Vendor Master (General Section)   ABAP Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

SET HANDLER, FOR

Short Reference



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

Additions

1. ... FOR oref

2. ... FOR ALL INSTANCES

3. ... ACTIVATION act

Effect

This statement registers the event handlers handler1 handler2 ... for the associated instance events of the objects specified after FOR. The addition ACTIVATION can be used to deregister event handlers or perform a dynamic registration.

An event handler is executed if the associated instance event is raised using RAISE EVENT in an object for which it is registered. An event handler handler can be specified as follows, where the names have the same meaning as in the explicit method call:

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

Methods meth can be specified from the same class or from other classes defined as instance event handlers using the addition FOR EVENT evt OF {class|intf} of the statements $[CLASS-$] METHODS. No event handlers for static events can be specified. At least one name must be specified.

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. Single objects or all handleable objects can be specified after the addition FOR.

Addition 1

... FOR oref

Effect

This addition registers or deregisters the event handlers of the list handler1 handler2 ... for exactly one object. 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 a subclass of class, or must implement the interface intf directly or through a superclass.

oref is a functional operand position.

Example

Registration of an event handler for an ALV event.

Addition 2

... FOR ALL INSTANCES

Effect

This addition registers or deregisters the event handlers of the list handler1 handler2 ... for all objects whose events they can handle. These are all objects whose classes are either class or the subclass of class, or which implement the interface intf directly or through a superclass. Such a registration also applies to all raising instances created after the statement SET HANDLER.

Note

Registration with FOR ALL INSTANCES applies also in particular to temporary instances that can be created when using the instantiation operator NEW.

Addition 3

... ACTIVATION act

Effect

A single-character text-like field act can be specified after the addition ACTIVATION. If act has the value "X" (the default value), the event handlers handler are registered. If act has the value " ", however, the registration of the event handlers handler is canceled. A single registration cannot, however, be deregistered using mass deregistration. Conversely, individual raising objects cannot be excluded from registration after a mass registration.

Note

As long as the registration of an instance method as an event handler for an instance event is not canceled using ACTIVATION " " or all raising instances are deleted, the associated object cannot be deleted by the Garbage Collector. This is because it is still used by the runtime framework.

Example

Registration of an event handler with FOR ALL INSTANCES. The events of all temporary instances created with NEW are handled until registration is stopped. The program can be executed as DEMO_SET_HANDLER_FOR_ALL.






BAL_S_LOG - Application Log: Log header data   CPI1466 during Backup  
This documentation is copyright by SAP AG.

Length: 6059 Date: 20240419 Time: 121309     sap01-206 ( 91 ms )