How to set the cell type as hotspots or Links in SAP ALV Display

The cell type of CL_GUI_ALV_GRID->MC_STYLE_HOTSPOT enables the user to navigate to a new page or session. It can also open a new window or display a list. It appears as a Link in the SAP ALV List.

The following steps are necessary to implement the HOTSPOT / LINKS

  1. Extent the Internal table with the additional field of type lvc_t_styl.
  2. Set the fields fieldname, style of lvc_t_Styl to each row of the ALV List. The column is specified in the fieldname.
  3. The stylename field of the layout is assigned with the fieldstyle component.

  • Extension of Internal table with Fieldstyle component

TYPES: BEGIN OF ty_contact_link.

              INCLUDE STRUCTURE ztt_db_table2.

TYPES: fieldstyle TYPE lvc_t_styl,

              END OF ty_contact_link.

  • Set the column in the SAP ALV List with the field style ‘CL_GUI_ALV_GRID=>mc_style_hotspot’.

DATA lt_contact TYPE TABLE OF ty_contact_link.

DATA ls_style TYPE lvc_s_styl.

FIELD SYMBOLS <ls_contact> TYPE ty_contact_link.

LOOP AT lt_contact ASSIGNING <ls_contact>.

ls_style-fieldname = ‘CONTACT_NAME’.

ls_style-style = cl_gui_alv_grid => mc_style_hotspot.

APPEND ls_style TO <ls_contact>-fieldstyle.

ENDLOOP

  • Setting the stylename field of the layout.

ls_layout-stylename = ’FIELDSTYLE’.

Note: The hotspot can be activated throught the field HOTSPOT of field catalog. The field HOTSPOT of the field catalog is set to ‘X’. The key advantage of this field is that the user does not have to add any additional field to the Internal table.