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

ABAP - OOPS: Events With Export Parameters.

Events can have export parameters, which it passes to its event handler method. The triggering method must pass values for all the exporting parameters of the event while raising the event using RAISE EVENT statement. The interface of an event handler method consists of a list of IMPORTING parameters, whose names are identical with those in the EXPORTING list and which are automatically created from the interface of the event. Each handler method can however specify which event parameters it wants to handle and which it does not.
-------------------------------------------------------------------------------------------
REPORT YSUBDEL1.

CLASS c1 DEFINITION.
PUBLIC SECTION.
EVENTS : E1 EXPORTING value(NUM1) TYPE I
value(NUM2) TYPE I.

METHODS : M1 FOR EVENT E1 OF C1
IMPORTING NUM1
NUM2
.
METHODS : T1.
ENDCLASS.

CLASS C1 IMPLEMENTATION.
METHOD : M1.
WRITE:/5 'First input ' , num1 .
write:/5 'Second input ' , num2 .
ENDMETHOD.

METHOD T1.
RAISE EVENT E1 exporting num1 = 2
num2 = 3.
ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
DATA : oref TYPE REF TO c1.
CREATE OBJECT oref.
SET HANDLER oref->M1 for oref.
call method oref->T1.

Output:
First input 2
Second input 3

No comments:

Post a Comment