Application Development 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: 

Hiding column in cl_salv_table

amysh95
Participant
0 Kudos

hey,

I am using cl_salv_table to dispay report and I need to hide some of my column present in gt_table I did this using SET_VISIBLE method.

TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = lt_table
CHANGING
t_table = gt_table
.
CATCH cx_salv_msg .
ENDTRY.
lt_function = lt_table->get_functions( ).
lt_function->set_all( abap_true ).
lr_columns = lt_table->get_columns( ).

" Hiding columns present in gt_table.
lr_column ?= lr_columns->get_column('PERIOD').
lr_column->set_visible( abap_false ).
lr_column ?= lr_columns->get_column('GJAHR').
lr_column->set_visible( abap_false ).
lr_column ?= lr_columns->get_column('ZTAG1').
lr_column->set_visible( abap_false ).

"Optimizing Column width
lr_columns->set_optimize('X').
lt_table->display( ).

this is ok it's hiding the column but when I use the function like sort in ascending order these hidden column is still present in that. how can I remove these entry also.

thanks in adv.

1 ACCEPTED SOLUTION

bruce_hartley
Active Participant

lr_column->set_technical should do this for you. This is from the class documentation as follows:

"By default, the user is provided with all columns as a column set. The user can decide for himself/herself, which of these columns from the column set he/she wants displayed or not.

You use the SET_TECHNICAL method to set whether the column is contained in the user's column set or not. The user never sees technical columns."

So your code would be:

lr_column->set_technical( abap_true ).

2 REPLIES 2

bruce_hartley
Active Participant

lr_column->set_technical should do this for you. This is from the class documentation as follows:

"By default, the user is provided with all columns as a column set. The user can decide for himself/herself, which of these columns from the column set he/she wants displayed or not.

You use the SET_TECHNICAL method to set whether the column is contained in the user's column set or not. The user never sees technical columns."

So your code would be:

lr_column->set_technical( abap_true ).

0 Kudos

bhartley thank you. It is working as I wanted.