Wednesday, December 16, 2015

OO ABAP: Event with Parameter

Event with Parameter

While raising an event, we can export parameter values. Later we can import these values in event-handler method and can be used for further data processing.

Please go through OO ABAP: Event  to see how to create simple event.

Following are the simple 5 steps for Raising & Handling event with parameter. 

1. Define an Event with parameter in a class 



2. Define a method with importing parameter (values will be imported from event)in same class or other class




3. Link event and method to convert the method into an event handler method. Click the above 'Detail view' button for linking.


4. Create a triggering method with parameter and raise the event exporting value for parameter.


5. Use SET HANDLER and register the event handler method for a particular instance in the program.


Sample Program 

REPORT  zdil_blog_event_para.

DATA: lo_class1 TYPE REF TO zdil_blog_class1,
      lo_class2 TYPE REF TO zdil_blog_class2.

START-OF-SELECTION.

  CREATE OBJECT lo_class1.
  CREATE OBJECT lo_class2.

  SET HANDLER lo_class2->event_handling_method FOR lo_class1.

  lo_class1->event_triggering_method( 'TEST_PARA' ).

Output




No comments:

Post a Comment