程序中e1是类事件,c1是类方法。我尝试使用类方法c1=>t1和对象方法c1->t1的调用调用类事件,两者都是成功的。为什么?如我们所知,类方法总是由c1=>t1调用。
REPORT my_event7.
CLASS c1 DEFINITION.
PUBLIC SECTION.
CLASS-EVENTS: e1.
METHODS: m1 FOR EVENT e1 OF c1.
CLASS-METHODS : t1.
ENDCLASS. "c1 DEFINITION
CLASS c1 IMPLEMENTATION.
METHOD : t1.
WRITE:/5 'C1->T1'.
RAISE EVENT e1.
ENDMETHOD.
METHOD : m1.
WRITE:/5 ' C1->M1'.
ENDMETHOD. ":
ENDCLASS. "c1 IMPLEMENTATION
CLASS c2 DEFINITION.
PUBLIC SECTION.
METHODS: m2 FOR EVENT e1 OF c1.
ENDCLASS. "c2 DEFINITION
CLASS c2 IMPLEMENTATION.
METHOD : m2.
WRITE:/5 ' C2->M2'.
ENDMETHOD.
ENDCLASS. "c2 IMPLEMENTATION
START-OF-SELECTION.
DATA: oref1 TYPE REF TO c1.
DATA: oref2 TYPE REF TO c2.
CREATE OBJECT: oref1 .
CREATE OBJECT: oref2 .
SET HANDLER oref1->m1 oref2->m2.
CALL METHOD c1=>t1.
CALL METHOD oref1->t1.
你可以称之为语法糖
类方法可以在没有<classname>=>method
实例的情况下调用。
但是您也可以通过类的实例调用类方法。然后您可以使用->
的普通方法调用。但是在后台调用类方法