Add / change column name in internal ALV table

I need to add headings to these two columns (highlighted in yellow), and I don't know how to do it.

Columns without the titles

FORM display_alv. 
    DATA: gr_functions TYPE REF TO cl_salv_functions.
    DATA: gr_display TYPE REF TO cl_salv_display_settings.    
    DATA: gr_columns TYPE REF TO cl_salv_columns_table.    
    DATA: gr_column TYPE REF TO cl_salv_column_table.    
    DATA: gr_sorts TYPE REF TO cl_salv_sorts.    
    DATA: gr_agg TYPE REF TO cl_salv_aggregations.    
    DATA: gr_selections TYPE REF TO cl_salv_selections.

    gr_functions = alv->get_functions( ).    
    gr_functions->set_all( abap_true ).

    gr_display = alv->get_display_settings( ).    
    gr_display->set_striped_pattern( cl_salv_display_settings=>true ).    
    gr_display->set_list_header( 'Relatório RVs' ).

    gr_columns = alv->get_columns( ).    
    gr_columns->set_optimize( 'X' ).    
    gr_columns = alv->get_columns( ).

    gr_column ?= gr_columns->get_column( 'revenue' ).    
    gr_column->set_short_text( 'Revenue' ).    
    gr_column->set_medium_text( 'Revenue' ).

    alv->display( ).
ENDFORM.`
+4
source share
1 answer

The syntax of some of these ALV methods is pretty sophisticated. I am sure that your code is correct, except that it revenueshould be in all caches. See the example below:

alv->get_columns( )->get_column( 'REVENUE' )->set_short_text( 'Revenue' ) ##NO_TEXT.
alv->get_columns( )->get_column( 'REVENUE' )->set_medium_text( 'Revenue ) ##NO_TEXT.
alv->get_columns( )->get_column( 'REVENUE' )->set_long_text( 'Revenue' ) ##NO_TEXT.
+3
source

Source: https://habr.com/ru/post/1676988/


All Articles