OO事件处理

class adding definition.
  public section.
    class-data num type i.
    events: return.
    methods: accumulate.
endclass.

class adding implementation.
  method accumulate.
    data: res type i.
    num = num + 1.
    res = num mod 10.
    if res = 0.
      raise event return.
    endif.
  endmethod.
endclass.

class handler1 definition.
  public section.
    methods: handle_execute for event return of adding.
endclass.

class handler1 implementation.
  method handle_execute.
    write:/ 'The present number is:', adding=>num.
  endmethod. 
endclass.

data: o_adding type ref to adding,
      o_handler type ref to handler1.
 
start-of-selection.
  create object:o_adding, o_handler.
  set handler o_handler->handle_execute for all instances."注册
 
do 50 times.
  call method o_adding->accumulate.
enddo. 


你可能感兴趣的:(OO事件处理)