Copyright 2023 - BV TallVision IT

How to make an ALV report respond to a hotspot clicks ? A brief demo on hotspot clicks, double clicks, ALV selections and handling menu actions. For key fields to other documents you can make the report more interactive with drill-down functionality to more detailed information. To respond to a double click (or single click / otspot click) you'll need to set up a method which will be called responding to the actual double click. To do this a local class is added to the program by filling in it's definition and its implementation. 


  1. Define a local (handler) class - lcl_event_manager
  2. The event manager should have a constructor and a method for handling user-command actions, double click and hotspot click. Each method should be set to respond to an event (respectively: added_function, double_click or click_link)
  3. The constructor should "set handlers" for the events, which will make the (local) class respond to the actual events
  4. Each method will be triggered when the event is thrown, and for each method an example processing response is available on the example
  5. The selection mode for the overall of the ALV was set to 2, multiple selection
  6. User command processing ('DO_IT') is simulated by typing it directly into the command box (adding a menu into a "ready-to-copy" abap coding example is not possible, so you will have to set your own menu)
  7. Note that a field should be set to "hotspot" to make the click link setup work, in the example this was done with field matnr

Example: Respond to a double click from a cell on the ALV grid

report  z_alv_interactive_demo.

class lcl_event_manager definition deferred.
data: gt_data type table of mara,
      gw_data type mara,
      go_salv type ref to cl_salv_table,
      go_event_man type ref to lcl_event_manager.

* Note - the user interface MAIN_MENU on this program was copied from
* CLASS lcl_event_manager DEFINITION
class lcl_event_manager definition.

  public section.
    methods: constructor importing r_object type ref to cl_salv_table,
             on_user_command for event added_function of cl_salv_events
               importing e_salv_function,
             on_double_click for event double_click of cl_salv_events_table
               importing row column,
             on_link_click for event link_click of cl_salv_events_table
               importing row column.
  private section.
    data: go_salv type ref to cl_salv_table.

endclass.                    "lcl_event_manager DEFINITION
* CLASS lcl_event_manager IMPLEMENTATION
class lcl_event_manager implementation.
  method constructor.
    data: lo_events type ref to cl_salv_events_table.

    go_salv = r_object.
    lo_events = go_salv->get_event( ).
    set handler on_user_command for lo_events.
    set handler on_double_click for lo_events.
    set handler on_link_click for lo_events.
  method on_user_command.
    data: lt_rows type salv_t_row,
          lv_row type int4,
          lo_selections type ref to cl_salv_selections.

    case e_salv_function.
      when 'DO_IT'. "<= An action from your menu
* Get the selected entries
        lo_selections = go_salv->get_selections( ).
        lt_rows = lo_selections->get_selected_rows( ).
        loop at lt_rows into lv_row.
          read table gt_data index lv_row into gw_data.
          gw_data-matnr = '*processed*'.
          modify gt_data index lv_row from gw_data.
        go_salv->refresh( ). "Will also display
  endmethod.                    "on_user_command
  method on_double_click.
    read table gt_data index row into gw_data.
    gw_data-matnr = '*doubleclicked*'.
    modify gt_data index row from gw_data.
    go_salv->refresh( ).
  endmethod.                    "on_double_click
  method on_link_click.
    read table gt_data index row into gw_data.
    gw_data-matnr = '*linkclicked*'.
    modify gt_data index row from gw_data.
    go_salv->refresh( ).
  endmethod.                    "on_link_click


  select * from mara into table gt_data up to 30 rows.

  cl_salv_table=>factory( importing r_salv_table = go_salv
                          changing t_table = gt_data ).

  data: lrf_selections type ref to CL_SALV_SELECTIONS,
        lrf_columns_table type ref to CL_SALV_COLUMNS_TABLE,
        lrf_column_table type ref to CL_SALV_COLUMN_TABLE.
* Set the selection mode: allow multiple lines to be selected
  lrf_selections = go_salv->get_selections( ).
  lrf_selections->set_selection_mode( 2 ).
* Set a field to clicklink field:
  lrf_columns_table = go_salv->get_columns( ).
  lrf_columns_table->set_optimize( abap_true ). "Always a good idea
  lrf_column_table ?= lrf_columns_table->get_column( 'MATNR' ).
  lrf_column_table->set_cell_type( if_salv_c_cell_type=>hotspot ).

  CREATE OBJECT go_event_man
      r_object = go_salv.

  go_salv->display( ).