*&---------------------------------------------------------------------*
*& Report YSAP_OOABAP_EVENTS_HANDLER
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ysap_ooabap_events_handler.
*----------------------------------------------------------------------*
* CLASS class1 DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS class1 DEFINITION.
PUBLIC SECTION.
EVENTS: event1.
METHODS: method1 FOR EVENT event1 OF class1.
METHODS: method2.
ENDCLASS. "class1 DEFINITION
*----------------------------------------------------------------------*
* CLASS class1 IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS class1 IMPLEMENTATION.
METHOD method1.
WRITE:/ 'the event handler method' COLOR 5.
ENDMETHOD. "method1
METHOD method2.
WRITE:/ 'method to raise event event1' COLOR 7.
RAISE EVENT event1.
ENDMETHOD. "method2
ENDCLASS. "class1 IMPLEMENTATION
START-OF-SELECTION.
DATA: object1 TYPE REF TO class1.
CREATE OBJECT object1.
SET HANDLER object1->method1 FOR object1.
CALL METHOD object1->method2.
OUTPUT:
*& Report YSAP_OOABAP_EVENTS_HANDLER
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ysap_ooabap_events_handler.
*----------------------------------------------------------------------*
* CLASS class1 DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS class1 DEFINITION.
PUBLIC SECTION.
EVENTS: event1.
METHODS: method1 FOR EVENT event1 OF class1.
METHODS: method2.
ENDCLASS. "class1 DEFINITION
*----------------------------------------------------------------------*
* CLASS class1 IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS class1 IMPLEMENTATION.
METHOD method1.
WRITE:/ 'the event handler method' COLOR 5.
ENDMETHOD. "method1
METHOD method2.
WRITE:/ 'method to raise event event1' COLOR 7.
RAISE EVENT event1.
ENDMETHOD. "method2
ENDCLASS. "class1 IMPLEMENTATION
START-OF-SELECTION.
DATA: object1 TYPE REF TO class1.
CREATE OBJECT object1.
SET HANDLER object1->method1 FOR object1.
CALL METHOD object1->method2.
No comments:
Post a Comment