Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I find out where the event is used in ABAP classes?

mykola_tokariev2
Explorer
3,423

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.

1 ACCEPTED SOLUTION

MateuszAdamus
Active Contributor
2,325

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,
Mateusz
11 REPLIES 11

MateuszAdamus
Active Contributor
2,325

Hi mykola.tokariev2

Did you check the Where-Used list of the event? Does it not answer your question?


Kind regards,
Mateusz

mykola_tokariev2
Explorer
0 Kudos
2,325

Hi mateuszadamus yes I did it, but its show me the same method where it RAISE...

I'm confused...

MateuszAdamus
Active Contributor
0 Kudos
2,325

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,
Mateusz

former_member1716
Active Contributor
0 Kudos
2,325

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!

former_member1716
Active Contributor
0 Kudos
2,325

mykola.tokariev2,

Can you tell us what is the information you are looking for?

Regards!

MateuszAdamus
Active Contributor
2,326

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,
Mateusz

0 Kudos
2,325

... 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?

2,325

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,
Mateusz

2,325

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.

0 Kudos
2,325

Mykola Tokariev I wonder what could be the meaning of an "event globally defined"... This non-official term is not a SAP concept...

mykola_tokariev2
Explorer
0 Kudos
2,325

satishkumarbalasubramanian I looked for method witch will be triggered with this event (add_material). But I found it, thanks.