2020 Jun 18 10:10 AM
Hello everyone,
I read this article Example of using Events in SAP OO ABAP classes and I can't understand how can I found out witch methods will be trigger if I RAISE some event.
2020 Jun 18 1:05 PM
Hello mykola.tokariev2
Don't be confused. 🙂 In this particular example, the method that is designed as an event handler is also triggering the event. If you create a test report with a test class, and in this class a test method with the FOR EVENT statement for this particular event, you will then see this test class and method in the Where-Used list.
You can read more about the FOR EVENT in the SAP Help.
Keep in mind that not all methods designed for handling an event will be executed. To have a method executed you need to register it for an event. You can do this with SET HANDLER.
Kind regards,2020 Jun 18 10:27 AM
Hi mykola.tokariev2
Did you check the Where-Used list of the event? Does it not answer your question?
2020 Jun 18 12:57 PM
Hi mateuszadamus yes I did it, but its show me the same method where it RAISE...
I'm confused...
2020 Jun 18 12:57 PM
Hi Mykola
That's just because the same method that is executed during the event also raises the event. Apparently there are no others handlers. But, if you create a test report in which you will create a test class with a handler for the event, the Where-Used list will show you that new class too.
You can also read about the FOR EVENT in SAP Help.
Keep in mind, that the Where-Used list shows you only methods which can be executed during the event. These methods still have to be registered for the event. SET HANDLER keyword does that.
Kind regards,2020 Jun 18 1:01 PM
mykola.tokariev2,
Am not sure if i understood your question right.
Are you asking when you raise an event which method will be triggered?
if Yes, well there wont be any method triggering rather the code lines written as part the events will be executed. You can double click on the event and find the code lines for the same.
Or
You want to find what are all the methods that triggers the event?
This Can be found out using the Where used List option.
Regards!
2020 Jun 18 1:03 PM
mykola.tokariev2,
Can you tell us what is the information you are looking for?
Regards!
2020 Jun 18 1:05 PM
Hello mykola.tokariev2
Don't be confused. 🙂 In this particular example, the method that is designed as an event handler is also triggering the event. If you create a test report with a test class, and in this class a test method with the FOR EVENT statement for this particular event, you will then see this test class and method in the Where-Used list.
You can read more about the FOR EVENT in the SAP Help.
Keep in mind that not all methods designed for handling an event will be executed. To have a method executed you need to register it for an event. You can do this with SET HANDLER.
Kind regards,2020 Jun 18 1:44 PM
... thank you for your help, I found that in my case, after RAISE EVENT ...
program jumps to complete another class ZCL_FW_DPS_PACK_MASTER
... and there method HANDLE_ADD_MATERIAL will be start.
Are EVENTS globally defined? How event knows witch class should be used?
2020 Jun 18 1:59 PM
Clearly, I missed out on a very important detail - the HANDLE_ADD_MATERIAL method defined in ZCL_FW_DPS_PACK_POSITION_ALV class is an instance private method, where the HANDLE_ADD_MATERIAL method showed by the Where-Used for the event is a static private method. From this I figure that the Where-Used showed you the method defined in the ZCL_FW_DPS_PACK_MASTER class and not the one defined in the ZCL_FW_DPS_PACK_POSITION_ALV class. Correct?
To answer your question - events are globally defined but a method needs to register to handle an event (SET HANDLER). This is how an event knows which methods should be called when it's raised.
In your case, keeping in mind the very important detail, I'm sure you will find somewhere in the ZCL_FW_DPS_PACK_MASTER class a SET HANDLER for the ADD_MATERIAL event, with the HANDLE_ADD_MATERIAL method.
In this case the method naming is not very fortunate...
Kind regards,2020 Jun 18 2:16 PM
Thank you mateuszadamus you are right. SET HANDLER for the ADD_MATERIAL event is in construct defined. But it was very important to know that events are globally defined.
2020 Jun 18 6:09 PM
Mykola Tokariev I wonder what could be the meaning of an "event globally defined"... This non-official term is not a SAP concept...
2020 Jun 18 1:57 PM
satishkumarbalasubramanian I looked for method witch will be triggered with this event (add_material). But I found it, thanks.