Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *&---------------------------------------------------------------------*
- *& Report ZZ_TEST_OBJ_EVT_LIFESPAN
- *& Registering an object for an event prevents it from being recycled
- *&---------------------------------------------------------------------*
- *& If you run into this problem: do not register "for all instances",
- *& but for particular instances. The handler will then be recycled
- *& together with the event triggerer, which in many cases solves the
- *& problem.
- *&---------------------------------------------------------------------*
- REPORT ZZ_TEST_OBJ_EVT_LIFESPAN.
- class a definition.
- public section.
- events: e.
- methods: raise.
- endclass.
- class b definition.
- public section.
- methods:
- m for event e of a,
- constructor.
- endclass.
- class a implementation.
- method raise.
- raise event e.
- endmethod.
- endclass.
- class b implementation.
- method m.
- write: / 'Handler called'.
- endmethod.
- method constructor.
- set handler m for all instances.
- endmethod.
- endclass.
- start-of-selection.
- data(go_a) = new a( ).
- perform start.
- form start.
- write: / 'First call'.
- perform test. " -> writes 'Handler called'
- write: / 'Second call'.
- perform test. " -> 'Handler called' will be written twice
- endform.
- form test.
- data(lo_b) = new b( ).
- go_a->raise( ).
- endform.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement