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: 
Read only

Enhance standard class with event handler method

Former Member
0 Likes
1,444

In trying to enhance a standard class with a new event handler class, I find that the ECC 6.0 EHP4 system does not appear to recognise the fact the method is an event handler method.  The specific example is a new method to handle the event CL_GUI_ALV_GRID->USER_COMMAND. 

I notice that the flag called Active has not been ticked - see image below.  Perhaps this is the reason why the event handler is not being triggered.

Note that there is an event handler for the same event in the standard class which obviously is executed as expected.  Any ideas on limitations in the system or I am missing a step?

Thanks
John

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
0 Likes
1,096

Looks like SAP doesn't allow to create event handler methods in the Enhancements, even the parameters are not getting inherited from the Event.

But for your purpose, I would suggest to add a Post-Exit method for the event handler method HANDLE_USER_COMMAND. This way you don't need to worry about registering your custom method as the event handler method using SET HANDLER.

Regards,
Naimesh Patel

4 REPLIES 4
Read only

Former Member
0 Likes
1,096

Halo John,

Why do you want to enhance standard class with Event handler method. Ideally the event handler method for  CL_GUI_ALV_GRID->USER_COMMAND event should be part of your class( Z namespace ).

Regards

Arshad

Read only

0 Likes
1,096

Thank you for your replies.

There is a bug in the ALV handler of a standard SAP class (when executed in ITS WebGUI) and I was hoping to create a custom event handler as an Enhancement to execute some custom code to sort of "handle the bug". 

I agree - ideally it should be done in a Z class but that will not give me access to the object methods and attributes of the enhanced class.

Cheers,
John

Read only

naimesh_patel
Active Contributor
0 Likes
1,097

Looks like SAP doesn't allow to create event handler methods in the Enhancements, even the parameters are not getting inherited from the Event.

But for your purpose, I would suggest to add a Post-Exit method for the event handler method HANDLE_USER_COMMAND. This way you don't need to worry about registering your custom method as the event handler method using SET HANDLER.

Regards,
Naimesh Patel

Read only

0 Likes
1,096

Hi Naimesh,

Unfortunately this does not work as the following error message is raised "The class has not yet been converted to the new class-local types".

I suppose I have to be satisfied with the conclusion that this is a limitation within SAP.

Cheers,
John