The columns can be renamed with the object of the class cl_salv_column_table. There are four methods available such as SET_SHORT_TEXT (), SET_MEDIUM_TEXT(), SET_LONG_TEXT and SET_TOOLTIP(). The method can be chosen based on our requirement of text length.
DATA lr_salv_columns_table TYPE REF TO cl_salv_columns_table.
DATA lr_salv_column_table TYPE REF TO cl_salv_column_table.
DATA lv_short_text TYPE scrtext_s.
DATA lv_medium_text TYPE scrtext_m.
DATA lv_long_text TYPE scrtext_l.
DATA lv_tip_text TYPE lvc_tip.
lr_salv_columns_table = lr_alv_grid -> get_columns ().
lr_salv_column_table ?= lr_salv_columns_table -> get_column(‘CONTACT_NAME’).
lv_short_text = ‘short_contact_name’.
lr_salv_column_table -> set_short_text (lv_short_text).
lv_medium_text = ‘medium_contact_name’.
lr_salv_column_table -> set_medium_text (lv_medium_text).
lv_long_text = ‘long_contact_name’.
lr_salv_column_table -> set_long_text (lv_long_text).
lv_tip_text = ‘tip_contact_name’.
lr_salv_column_table -> set_tooltip(lv_tip_text).
If you wish to force the ABAP execution to use the short text instead of other texts, then there is an easy way to achieve this. Just ignore assigning the medium and long text, then it automatically considers the short text. The other two text formats are ignored by default.