sapdev logo background
sapdev logo sapdev logo
Comments

ABAP CLASS-METHODS EVENT HANDLER Statement syntax, information and example SAP source code



Return to Statement index



CLASS-METHODS - FOR EVENT

Short Reference

ABAP Syntax CLASS-METHODS meth
FOR EVENT evt OF {class|intf}
[IMPORTING p1 p2 ...[sender]].

What does it do? This statement declares the static method meth as the event handler for the event evt of the class class or the interface intf . The syntax and meaning of the additions are identical to the declaration of instance methods as event handlers .
Static event handlers can be called by the event evt independently of an instance of the class.

Example ABAP Coding In the class dialog_box , a static event handler close_box is defined for the event that is triggered when the user chooses to close a Control Framework ( CFW ) dialog box.
CLASS dialog_box DEFINITION.
PUBLIC SECTION.
METHODS constructor.
...
PRIVATE SECTION.
CLASS-DATA open_boxes TYPE i.
CLASS-METHODS close_box
FOR EVENT close OF cl_gui_dialogbox_container
IMPORTING sender.
...
ENDCLASS.

CLASS dialog_box IMPLEMENTATION.
METHOD constructor.
... " create a dialogbox
open_boxes = open_boxes + 1.
ENDMETHOD.
METHOD close_box
... " close the dialogbox referred by sender
open_boxes = open_boxes - 1.
ENDMETHOD.
ENDCLASS.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




CLASS-METHODS_CONSTRUCTOR
CLASS-METHODS_FUNCTIONAL




comments powered by Disqus