0

My ABAP report creates a list of locked records and presents them as an ALV grid. For this I use the class cl_gui_alv_grid. To make the processing of the reported data records more efficient, it should be possible to jump directly from the list to transaction PA20 (infotype, start date, end date).

The list has the following structure:

  • personnel number
  • infotype
  • start date
  • end date

Is this possible?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Poseidon
  • 45
  • 6
  • Does this answer your question? [How to trigger code when the user clicks an ALV hotspot field?](https://stackoverflow.com/questions/68456861/how-to-trigger-code-when-the-user-clicks-an-alv-hotspot-field) – Suncatcher Aug 22 '23 at 06:40

1 Answers1

1

Yes, this should be possible.

First you would need to implement an event handler for the event double_click of cl_gui_alv_grid. You do that by creating a local class with an event handler method:

CLASS lcl_alv_event_handler DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
      on_double_click FOR EVENT double_click OF cl_gui_alv_grid
        IMPORTING e_row e_column es_row_no.
ENDCLASS.

Then you need to implement the method on_double_click to read the clicked line from your data table using the content of the parameter e_row and then use CALL TRANSACTION to start the transaction PA20. You can also perform some actions in the transaction PA20 before giving control to the user, like entering a personnel number or the time and then performing the "view" action. You do that by passing a table with batch-input actions using the addition USING bdc_tab to CALL TRANSACTION. More about that in the documentation which also includes an example how to do it with a batch input table.

Then you assign that event handler after you created your ALV grid:

SET HANDLER lcl_alv_event_handler=>on_double_click FOR go_alv.
Philipp
  • 67,764
  • 9
  • 118
  • 153
  • Thanks a lot for your answer. In the first step I try to show the clicked cell by a message. But nothing happens. `CLASS lcl_alv_event_handler DEFINITION. PUBLIC SECTION. CLASS-METHODS: on_double_click FOR EVENT double_click OF cl_gui_alv_grid IMPORTING e_row e_column es_row_no. ENDCLASS. CLASS lcl_alv_event_handler IMPLEMENTATION. METHOD on_double_click. MESSAGE 'Row clicked.' & 'e_row' TYPE 'I'. ENDMETHOD. ENDCLASS. ` – Poseidon Mar 24 '23 at 14:02
  • Event handlers don't just need to be defined, they need to be assigned to a specific instance of the class they are supposed to react to. Did you set this method as the event handler for your cl_gui_alv_grid instance using the SET HANDLER keyword? – Philipp Mar 24 '23 at 14:36