Cell Action on ALV
Interface IF_SALV_GUI_TABLE_IDA provides method FIELD_CATALOG which returns reference of IF_SALV_GUI_FIELD_CATALOG_IDA.
Interface IF_SALV_GUI_FIELD_CATALOG_IDA provides method DISPLAY_OPTIONS which provides a referenc of IF_SALV_GUI_FIELD_DISPLAY_OPT
The interface IF_SALV_GUI_FIELD_DISPLAY_OPT provides method DISPLAY_AS_LINK_TO_ACTION to enable link to action for the field an the event CELL_ACTION
Event CELL_ACTION provides reference of IF_SALV_GUI_ROW_DATA_IDA which has a method GET_ROW_DATA to read the row data.
Code:
CLASS lcl_handle_ca DEFINITION.
PUBLIC SECTION.
METHODS handle_cell_action
FOR EVENT cell_action OF if_salv_gui_field_display_opt
IMPORTING ev_field_name eo_row_data.
ENDCLASS.
CLASS lcl_handle_ca IMPLEMENTATION.
METHOD handle_cell_action.
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_ca.
cl_salv_gui_table_ida=>create(
EXPORTING
iv_table_name = ‘SFLIGHT’
RECEIVING
ro_alv_gui_table_ida = lr_salv ).
DATA(lr_fld_disp) = lr_salv->field_catalog( )->display_options( ).
* Enable link to action
lr_fld_disp->display_as_link_to_action( iv_field_name = ‘CARRID’ ).
CREATE OBJECT lr_handle.
SET HANDLER lr_handle->handle_cell_action FOR ALL INSTANCES.
* Display ALV
lr_salv->fullscreen( )->display( ).
Output- Link to Action is enabled for the field CARRID.
One click we get the popup with row data.