Add/Change Column Name on Internal Table ALV

半腔热情 提交于 2019-12-01 21:34:01

问题


What I need is to add titles to these two columns (highlighted in yellow) and I don't know how to do that.

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.`

回答1:


The syntax for some of these ALV methods are pretty finicky. I'm pretty sure that your code is right, except that revenue needs to be in all caps. 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.


来源:https://stackoverflow.com/questions/43933515/add-change-column-name-on-internal-table-alv

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!