A new column can be inserted in to the SAP ALV list by adjusting the following two entities.
- Structure or Type of the table.
- New entry in the field catalog internal table.
- Structure or Type of the Table.
A local type is created with the new column.
TYPES: BEGIN OF ty_contact.
INCLUDE STRUCTURE ztt_db_table2.
TYPES: new_contact_address TYPE char0064.
END OF ty_contact.
- Insertion of new column details entry in field catalog.
DATA ls_field_cat TYPE lvc_s_fcat.
ls_field_cat -col_pos = 5.
ls_field_cat -fieldname = ‘NEW_CON_ADD’.
ls_field_cat -inttype = ‘C’.
ls_field_cat -datatype = ‘CHAR’.
ls_field_cat -intlen = 64.
ls_field_cat -scrtext_s= ‘New’.
ls_field_cat -scrtext_m= ‘New Contact’.
ls_field_cat -scrtext_l= ‘New Contact Address’.
APPEND ls_field_cat TO lt_field_cat.