Copyright 2024 - BV TallVision IT

Tooltips are not the first thing that presents itself when composing an ALV report. When your user hovers over a field, the tooltip text is revealed which can be a great additive to reports with a lot of columns. Also screen-to-speach software like Jaws can use tooltips to make reports more accessible to the visually impaired. 

There is a serious list of icons available (check out report SHOWICON), but a tooltip can really make a difference when multiple icons are used. The screenprint below doesn't show the mouse pointer, as it is hovering over the yellow traffic light icon:

The coding for this example:

report ZDEMO_ALV_5_TOOLTIPS.

include ZABAPCADABRA_EASY_ALV.
types: begin of ty_content,
         status type c, "Exception status field
         matnr type mara-matnr,
         icon type icon-id, "Icon code (assign manualy)
         mtart type mara-mtart,
       end of ty_content.
data: gt_data type table of ty_content,
      gw_data type ty_content,
      go_alv type ref to lcl_easy_alv.     "Define

start-of-selection.

  select matnr mtart from mara
    up to 20 rows
    into corresponding fields of table gt_data
    where mtart = 'DIEN'.

  data: lv_single_character type c.
* Just a bit of logic to create test data
  loop at gt_data into gw_data.
    lv_single_character = sy-tabix mod 4.
    gw_data-status = lv_single_character.
    case lv_single_character.
      when '0'. gw_data-icon = '@AB@'.
      when '1' or '2'. gw_data-icon = '@AC@'.
      when '3'. gw_data-icon = '@AD@'.
    endcase.
    modify gt_data from gw_data.
  endloop.

  create object go_alv.                 "Create
  go_alv->set_alv_from_template(
    changing content = gt_data ).   "Assign
  go_alv->set_field( fieldname = 'STATUS'
    is_exception = abap_true ).
  go_alv->set_field( fieldname = 'ICON'
    description_overall = 'Status'(003)
    tooltip = 'Processing status'(004)
    is_icon = abap_true ).
* For the "general tooltips" a list of values and tooltip
* descriptions are applied to actual field values in the
* ALV report. Icons:
  go_alv->add_general_tooltip(
    type = cl_salv_tooltip=>c_type_icon
    value = '@AB@'
    tooltip = 'Clear description of Icon'(005) ).
  go_alv->add_general_tooltip(
    type = cl_salv_tooltip=>c_type_icon
    value = '@AC@'
    tooltip = 'Processed fine'(006) ).
* Exceptions:
  go_alv->add_general_tooltip(
    type = cl_salv_tooltip=>c_type_exception
    value = '0'
    tooltip = 'Lights OUT!'(008) ).
  go_alv->add_general_tooltip(
    type = cl_salv_tooltip=>c_type_exception
    value = '1'
    tooltip = 'Red traffic light'(007) ).

  go_alv->display( ).                      "Report