Application Development 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: 

In ADT is there a QuickFix to create event handlers (ABAP OO)

Sandra_Rossi
Active Contributor

Hi,

Every time I have to define a event handler, I do it completely manually, by typing the following lines, without assistance from Eclipse ADT to propose the available events of the object type I choose:

METHODS on_event FOR EVENT eventname OF objecttype IMPORTING ...

somewhere else, I enter:

SET HANDLER on_event FOR object.

Hopefully, there is one QuickFix to propose the possible parameters of the event, and another one to create the empty method implementation.

But I find it quite cumbersome to have to go to the object type, list its events, copy/paste them, then type the text around.

Do you know any QuickFix or tip to accelerate the typing of the event handlers?

Thank you.

Sandra

NB: the context how I use it is that I defined a dynpro application with view classes (MVC) with one event per user action, and the controller class handles each event.

1 ACCEPTED SOLUTION

BiberM
Active Participant

No, I don't think so.

But that could be something for Enno Wulffs Quick fixes extension.

11 REPLIES 11

BiberM
Active Participant

No, I don't think so.

But that could be something for Enno Wulffs Quick fixes extension.

enno.wulff ?

BiberM
Active Participant

Your are right! It was not him.

And sorry 28f4b37a40894f18a22abc696b8154f4 for not thinking of you!

Link to the plugin: ABAP Quick Fix

Sandra_Rossi
Active Contributor

Thank you Chaouki Akir and Michael Biber, I will have a look at Łukasz Pęgiel ABAP Quick Fixes. If one of them has resemblances with the one I'm looking for, I'll try to propose a new one... (but I'm not really confident because event handler implies to work with two repository objects at the same time, the "event handler" class and the object type defining the events, eventually display a dialog to choose the events, so it's not easy for a java newbie). NB: I posted a feature request.

My Quick Fixes doesn't allow this, as they work only on visible part of the source code. I do not call backend which would be needed to check the parameters of event. But I was almost sure that we have already such quick fix from ADT itself. So I've checked this and:

1) You can get the importing parameters but not using Ctrl+1 but Ctrl+Space after the importing statement

2) If your class contains events or inherits from the class that have one, you can also do Ctrl+Space for the event name. Do get this you need to write the class whole syntax beside the name of the event and then use Ctrl+Space

Not perfect but always something.

You could also prepare a template for creation of the event handlers, then it make this faster.

Cheers

Łukasz

Sandra_Rossi
Active Contributor
0 Kudos

Thank you Łukasz Pęgiel. That's good news. I guess I have to install the latest ADT/Eclipse 2020-06. Mine is only 2020-03.

0 Kudos

sandra.rossi as far as I know it is already available since long time, so 2020-03 should contain this functionality.

Sandra_Rossi
Active Contributor
0 Kudos
28f4b37a40894f18a22abc696b8154f4 Weird. I guess it works only with a sufficient support package. I tried with ABAP 7.52 SP 0 and 1. I type this code and press Ctrl+Space between the words EVENT and OF, and nothing happens. I tested in a brand new class pool, and in a brand new executable program.
CLASS lcl_app DEFINITION PUBLIC FINAL...
PUBLIC SECTION.
METHODS event FOR EVENT | OF cl_gui_alv_grid. " <==== pipe is not a character, it's the caret (then Ctrl+Space)
ENDCLASS.
CLASS lcl_app IMPLEMENTATION.
ENDCLASS.

0 Kudos

sandra.rossi the event selection works only if the event is declared in the same class or in supper-class. The importing of parameters should work always.

Sandra_Rossi
Active Contributor

Łukasz Pęgiel Thanks a lot, now it's clear!

Yes it works in my system too, now I see "myevent" appear as possible choice:

CLASS lcl_app DEFINITION PUBLIC FINAL...
PUBLIC SECTION.
EVENTS myevent.
METHODS event FOR EVENT | OF lcl_app. " <==== pipe is not a character, it's the caret (then Ctrl+Space)
ENDCLASS.
CLASS lcl_app IMPLEMENTATION.
ENDCLASS.

NB: I just debugged the ADT backend logic, and I could see that the code completion, at least for this case but probably for all code completions, is done by the Kernel method GET_COMPLETION_RESULT of CL_ABAP_PARSER.