REPORT zdemo01.
CLASS cl_driver DEFINITION.
PUBLIC SECTION.
EVENTS:max EXPORTING VALUE(iv_max) TYPE i.
METHODS:speed,
change_speed FOR EVENT max OF cl_driver
IMPORTING iv_max,
write.
PRIVATE SECTION.
DATA:gv_sd TYPE i.
ENDCLASS.
CLASS cl_driver IMPLEMENTATION.
METHOD speed .
gv_sd = gv_sd + 1.
IF gv_sd GT 5.
RAISE EVENT max EXPORTING iv_max = 5.
ENDIF.
ENDMETHOD.
METHOD change_speed .
gv_sd = iv_max.
ENDMETHOD.
METHOD write.
WRITE / gv_sd.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA(go_driver) = NEW cl_driver( ).
"设置事件处理器
SET HANDLER go_driver->change_speed FOR go_driver.
DO 10 TIMES.
CALL METHOD go_driver->speed.
CALL METHOD go_driver->write.
ENDDO.
阅读(1500) | 评论(0) | 转发(0) |