Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Changing Column header text ol ALV: Object ref cl_salv_table

Former Member
0 Likes
20,222

Hi Friends,

my code:

TRY.

CALL METHOD cl_salv_table=>factory(

EXPORTING

r_container = gv_custom_container

container_name = 'CUSTOM_300'

IMPORTING

r_salv_table = gr_table

CHANGING

t_table = gt_itab_email ).

CATCH cx_salv_msg. "#EC NO_HANDLER

CLEANUP.

ENDTRY.

activate ALV generic Functions

DATA: lr_functions TYPE REF TO cl_salv_functions_list.

TRY.

lr_functions = gr_table->get_functions( ).

lr_functions->set_default( abap_true ).

gr_columns = gr_table->get_columns( ).

*******************************************************

  • PERFORM change_columns_text USING gr_columns.

*******************************************************

gr_columns->set_exception_column( value = 'LIGHTS' ).

CATCH cx_salv_data_error.

CLEANUP.

ENDTRY.

CALL METHOD gr_table->display.

Problem:

Can someone give me tips on how to change the Column text of the return table gr_table in my code.

I would like to change the text before CALL METHOD gr_table->display.

Thanks

Blacky

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
7,961

You need to get the perticular column object from the COLUMNS object

Like:


  data: lr_columns type ref to cl_salv_columns_table,
        lr_column  type ref to cl_salv_column_table.

  lr_columns = gr_table->get_columns( ).

  try.
      lr_column ?= lr_columns->get_column( 'FIELD1' ).
      lr_column->set_short_text( 'Custom Text' ).
      lr_column->set_medium_text( 'Custom Text' ).
      lr_column->set_long_text( 'Custom Text' ).
    catch cx_salv_not_found.                            "#EC NO_HANDLER
  endtry.

Check report: SALV_DEMO_TABLE_COLUMNS

Regards,

Naimesh Patel

Hi Friends,

my code:

TRY.

CALL METHOD cl_salv_table=>factory(

EXPORTING

r_container = gv_custom_container

container_name = 'CUSTOM_300'

IMPORTING

r_salv_table = gr_table

CHANGING

t_table = gt_itab_email ).

CATCH cx_salv_msg. "#EC NO_HANDLER

CLEANUP.

ENDTRY.

activate ALV generic Functions

DATA: lr_functions TYPE REF TO cl_salv_functions_list.

TRY.

lr_functions = gr_table->get_functions( ).

lr_functions->set_default( abap_true ).

gr_columns = gr_table->get_columns( ).

*******************************************************

  • PERFORM change_columns_text USING gr_columns.

*******************************************************

gr_columns->set_exception_column( value = 'LIGHTS' ).

CATCH cx_salv_data_error.

CLEANUP.

ENDTRY.

CALL METHOD gr_table->display.

Problem:

Can someone give me tips on how to change the Column text of the return table gr_table in my code.

I would like to change the text before CALL METHOD gr_table->display.

Thanks

Blacky

2 REPLIES 2
Read only

naimesh_patel
Active Contributor
7,962

You need to get the perticular column object from the COLUMNS object

Like:


  data: lr_columns type ref to cl_salv_columns_table,
        lr_column  type ref to cl_salv_column_table.

  lr_columns = gr_table->get_columns( ).

  try.
      lr_column ?= lr_columns->get_column( 'FIELD1' ).
      lr_column->set_short_text( 'Custom Text' ).
      lr_column->set_medium_text( 'Custom Text' ).
      lr_column->set_long_text( 'Custom Text' ).
    catch cx_salv_not_found.                            "#EC NO_HANDLER
  endtry.

Check report: SALV_DEMO_TABLE_COLUMNS

Regards,

Naimesh Patel

Read only

0 Likes
7,961

Thanks a lot.

Problem solved and I gave max point.

Blacky