How to change Short, medium and long text of column
Class: CL_SALV_COLUMN_TABLE
Methods:
- SET_LONG_TEXT
- SET_MEDIUM_TEXT
- SET_SHORT_TEXT
The ALV report by default displays the short, medium and long text of field entered in Data dictionary. But if there is a requirement to change the field name in ALV report the below code can be used.
REPORT ztest_alv. DATA: lo_alv TYPE REF TO cl_salv_table. DATA: lo_display TYPE REF TO cl_salv_display_settings. DATA: lo_columns TYPE REF TO cl_salv_columns_table. DATA: lo_column TYPE REF TO cl_salv_column_table. DATA: ls_color TYPE lvc_s_colo. START-OF-SELECTION. SELECT * FROM spfli INTO TABLE @DATA(lt_spfli). IF sy-subrc IS INITIAL. cl_salv_table=>factory( IMPORTING r_salv_table = lo_alv CHANGING t_table = lt_spfli[] ). lo_columns = lo_alv->get_columns( ). lo_column ?= lo_columns->get_column( columnname = 'FLTYPE' ). lo_column->set_long_text( value = 'This is long text' ). lo_column->set_medium_text( value = 'This is med text' ). lo_column->set_short_text( value = 'This is sh' ). lo_alv->display( ). ENDIF.