Google Search - Blog...........

ABAP - OOPS: Use Of Static Event.

REPORT YSUBOOPS7 .

CLASS c1 DEFINITION.
PUBLIC SECTION.
* Creating event : E1
CLASS-EVENTS: E1.
* Creating an event handling method.
METHODS: M1 FOR EVENT E1 OF c1.
* Method to raise the event
CLASS-METHODS : T1.
ENDCLASS.

CLASS c1 IMPLEMENTATION.
* Method : T1 will raise the event
METHOD : T1.
write:/5 'I am T1, going to raise event E1'.
raise event E1.
ENDMETHOD.
* Method : M1 will be called when the event is raised
METHOD : M1.
write:/5 ' I am the event handler method M1 in c1'.
ENDMETHOD.
ENDCLASS.


Start-of-selection.
Data: oref1 type ref to c1.
Create object: oref1 .
* Registering the event handler method
SET HANDLER oref1->M1 .
* Calling the event which will raise the event.
call method oref1->T1.

Output:

I am T1, going to raise event E1
I am the event handler method M1 in c1

No comments:

Post a Comment