0

Hi guys!

I found a program on the internet that runs row details when I double-click the 'CARRID' cell on ALV. How to rewrite this code so that the details are displayed no matter what cell in the table I click, not only in 'CARRID'?

CLASS lcl_handle_dc DEFINITION.
  PUBLIC SECTION.
  METHODS double_click
        FOR EVENT double_click OF if_salv_gui_table_display_opt
        IMPORTING ev_field_name eo_row_data.
ENDCLASS.

CLASS lcl_handle_dc IMPLEMENTATION.
  METHOD double_click.
    DATA: ls_sflight TYPE sflight.
   CHECK ev_field_name = 'CARRID'.
* read the row data
   eo_row_data->get_row_data(
     EXPORTING
       iv_request_type = if_salv_gui_selection_ida=>cs_request_type–all_fields
     IMPORTING
       es_row = ls_sflight ).
* Display the row data
cl_salv_ida_show_data_row=>display( iv_text = 'Flight Row Info' is_data = ls_sflight ).
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
DATA: lr_salv TYPE REF TO if_salv_gui_table_ida,
      lr_handle TYPE REF TO lcl_handle_dc.
cl_salv_gui_table_ida=>create(
  EXPORTING
    iv_table_name       =  'SFLIGHT'
  RECEIVING
    ro_alv_gui_table_ida = lr_salv ).

DATA(lr_disp) = lr_salv->display_options( ).
* Enable double click
lr_disp->enable_double_click( ).
CREATE OBJECT lr_handle.
SET HANDLER lr_handle->double_click FOR ALL INSTANCES.

* Display ALV
lr_salv->fullscreen( )->display( ).
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Abapito
  • 73
  • 7
  • 1
    There's only one line in your program which refers to `CARRID`. Have a look at the ABAP documentation concerning `CHECK`, and revert back if anything remains unclear. – Sandra Rossi Jul 15 '22 at 17:13
  • For information, if you have "thought better of your question, you can delete it](https://stackoverflow.com/help/what-to-do-instead-of-deleting-question). – Sandra Rossi Jul 16 '22 at 08:16

1 Answers1

1

Remove the below line of code.

CHECK ev_field_name = 'CARRID'.

The CHECK statement ensures that the logical expression that follows evaluates to abap_true before continuing executing the next statements.

Dustin
  • 693
  • 8
  • 20