How to fill icons in SAP ALV Display of type CL_SALV_TABLE

In order to fill icons in ALV Table, we must add an additional field of type ICON_D. The type ICON_D is of datatype CHAR with length 4. This is later filled with the icon code.

Step1: Define the icon field

TYPE-POOLS: icon.

TYPES: BEGIN OF ty_contact.

                  INCLUDE STRUCTURE ztt_db_table2.

                  TYPES: icon_field TYPE icon_d,

               END OF ty_contact.

Step2: Fill the internal table with data contents.

DATA lt_contact TYPE TABLE OF ty_contact.

SELECT * FROM ztt_db_table2 INTO TABLE lt_contact.

Step3: Fill the internal table with icon code.

FIELD-SYMBOLS <ls_contact> TYPE ty_contact.

LOOP AT lt_contact ASSIGNING <ls_contact>.

               <ls_contact>-icon = icon_positive.

ENDLOOP.