[ABAP] SALV IDA: Klick-Events (Link, Button, Doppelklick) abfangen

CLASS lcl_events DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS: on_cell_click FOR EVENT cell_action OF if_salv_gui_field_display_opt
      IMPORTING
          ev_field_name
          eo_row_data
          sender.

    CLASS-METHODS: on_double_click FOR EVENT double_click OF if_salv_gui_table_display_opt
      IMPORTING
          ev_field_name
          eo_row_data
          sender.
ENDCLASS.

CLASS lcl_events IMPLEMENTATION.

  METHOD on_cell_click.
    DATA: lv_row TYPE sflight.

    eo_row_data->get_row_data( EXPORTING
                                 iv_request_type = if_salv_gui_selection_ida=>cs_request_type-all_fields
                               IMPORTING
                                 es_row = lv_row ).

    cl_salv_ida_show_data_row=>display( iv_text = |Datenfeld: { ev_field_name }|
                                        is_data = lv_row ).
  ENDMETHOD.

  METHOD on_double_click.
    DATA: lv_row TYPE sflight.

* Daten der geklickten Zeile holen
    eo_row_data->get_row_data( EXPORTING
                                 iv_request_type = if_salv_gui_selection_ida=>cs_request_type-all_fields
                               IMPORTING
                                 es_row =  lv_row ).

* Daten anzeigen
    cl_salv_ida_show_data_row=>display( iv_text = |Datenfeld: { ev_field_name }|
                                        is_data = lv_row ).
  ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.

  DATA(o_alv) = cl_salv_gui_table_ida=>create( iv_table_name = 'SFLIGHT' ).

* Single-Selection
  o_alv->selection( )->set_selection_mode( if_salv_gui_selection_ida=>cs_selection_mode-single ).

* Zellen der Spalte 'CONNID' sind als Link klickbar
  o_alv->field_catalog( )->display_options( )->display_as_link_to_action( iv_field_name = 'CONNID' ).
  SET HANDLER lcl_events=>on_cell_click FOR o_alv->field_catalog( )->display_options( ).

* Zellen der Spalte 'CARRID' sind als Button klickbar
  o_alv->field_catalog( )->display_options( )->display_as_button( iv_field_name = 'CARRID' ).
  SET HANDLER lcl_events=>on_cell_click FOR o_alv->field_catalog( )->display_options( ).

* Double-Click für alle Zellen
  o_alv->display_options( )->enable_double_click( ).
  SET HANDLER lcl_events=>on_double_click FOR o_alv->display_options( ).

* Tabelle anzeigen
  o_alv->fullscreen( )->display( ).