07-31-2020 9:54 AM
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.
07-31-2020 11:43 AM
No, I don't think so.
But that could be something for Enno Wulffs Quick fixes extension.
07-31-2020 10:14 AM
I don't find it in this list
https://blogs.sap.com/2013/06/05/adt-feature-availability-matrix-for-as-abap-releases/
07-31-2020 11:43 AM
No, I don't think so.
But that could be something for Enno Wulffs Quick fixes extension.
08-01-2020 8:41 PM
08-01-2020 8:50 PM
Your are right! It was not him.
And sorry 28f4b37a40894f18a22abc696b8154f4 for not thinking of you!
Link to the plugin: ABAP Quick Fix
08-02-2020 7:56 AM
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.
08-02-2020 12:40 PM
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
08-03-2020 8:31 PM
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.
08-03-2020 10:15 PM
sandra.rossi as far as I know it is already available since long time, so 2020-03 should contain this functionality.
08-04-2020 8:27 AM
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.
08-04-2020 10:54 AM
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.
08-04-2020 11:02 AM
Ł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.