Mentor SAP
2017-07-05 Submitted by:- Admin

One event can have more than one event handler method in the same class or in different classes. At the run time only one handler method will be triggered at a time. After triggering the one that has to be deactivated and then another handler method will have to be registered to be triggered. In this way, the system can register multiple event handler methods to the same event.

 

The following program contains a class cls1 wherein the public section we declare data v_cls1, event evnt, triggering method trig and event handler method evnthand1 for event evnt of class cls1. Now at the time of implementation we display a text in event handler method evnthand1 then we display another text in triggering method trig.

 

Next, we have defined another class cls2 wherein the public section we declare data and another event handler method evnthand2 for event evnt of class cls1. In the implementation, we display a text in this method.

 

Finally, in the start of selection, we have created object obj1 for cls1 and obj2 for cls2. Now we set handler method evnthand1 for object obj1 and then call triggering method trig. After that, we deactivate the registration of evnthand1 and then register again evnthand2 for obj1 by obj2. Then again we call the method trig. Hence initially we have registered the first handler method to the event and call the trigger. Then we have deactivated the registration to register the second handler method and called the same trigger again.