[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( ).

[ABAP] SALV-Table Eventhandling

* mögliche Events sind:
* SET HANDLER gr_events->on_user_command FOR o_alv->get_event( ).
* SET HANDLER gr_events->on_before_user_command FOR o_alv->get_event( ).
* SET HANDLER gr_events->on_after_user_command FOR o_alv->get_event( ).
* SET HANDLER gr_events->on_double_click FOR o_alv->get_event( ).
* SET HANDLER gr_events->on_top_of_page FOR o_alv->get_event( ).
* SET HANDLER gr_events->on_end_of_page FOR o_alv->get_event( ).
 
* Klasse für Eventhandling definieren
CLASS lcl_events DEFINITION.
  PUBLIC SECTION.
* Doppelklick
    CLASS-METHODS: on_double_click FOR EVENT double_click OF cl_salv_events_table
      IMPORTING
          row
          column
          sender.
* Link-Klick
    CLASS-METHODS: on_link_click FOR EVENT link_click OF cl_salv_events_table
      IMPORTING
          row
          column
          sender.
ENDCLASS.
 
CLASS lcl_events IMPLEMENTATION.
  METHOD on_double_click.
    MESSAGE | { row } , { column } | TYPE 'I'.
  ENDMETHOD.
  METHOD on_link_click.
    MESSAGE | { row } , { column } | TYPE 'I'.
  ENDMETHOD.
ENDCLASS.
 
DATA: o_salv TYPE REF TO cl_salv_table.

...
 
* Handler registrieren
SET HANDLER lcl_events=>on_double_click FOR o_salv->get_event( ).
SET HANDLER lcl_events=>on_link_click FOR o_salv->get_event( ).