There are three key steps involved in displaying an icon with Infotext in the cells of SAP ALV List.
- Extension of Internal table with an additional field of type char40.
- Fill the additional field with icon name and information text.
- Assign the new field to field catalog.
- Extension of Internal table with an additional field of type char40.
TYPES: BEGIN OF ty_contact.
INCLUDE STRUCTURE ztt_db_table2.
TYPES: icon_text TYPE char40,
END OF ty_contact.
DATA lt_contact TYPE TABLE OF ty_contact.
- Filling the internal table with icon and information text.
SELECT * FROM ztt_db_table2 INTO TABLE lt_contact.
LOOP AT lt_contact ASSIGNING FIELD-SYMBOL (<ls_contact>).
<ls_contact>-icon_text = ‘@09\Q Info_text @’.
ENDLOOP.
The value of field icon_text is based on the format ‘@xyz\Q info_text @’
The value of xyz in the above format is determined based on our needs. The various ICON codes are available through the type group ‘ICON’.
Transaction -> SE11.
Type Group -> Enter ‘ICON’ in Type group.
It will list the available icon ids.
Note: Please don’t forget to give a space character after ‘Q’ and before the @symbol.
The user can give their own text instead of info_text in the format mentioned above.
In our example, we have considered the icon ‘ICON_YELLOW_LIGHT’. It’s ID is ‘@09@’.
- Assignment of field ‘icon’ to field catalog.
DATA ls_field_Cat TYPE lvc_s_fcat.
ls_field_cat-fieldname = ‘ICON_TEXT’.
ls_field_cat-icon = ‘X’.
ls_field_cat-outputlen = 40.
APPEND ls_field_cat TO lt_field_cat.