cancel
Showing results for 
Search instead for 
Did you mean: 

remove columns from alv grid in runtime

Former Member
0 Kudos

hi,

how do we remove a particular column from an alv grid in runtime.

and also let me know how do we find wether a column is empty or not in runtime.

Thanks & Regards,

Ritwik.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

hi ritwik,

The table u r passing to alv has to be checked whether it has any empty colums.

only those columns has to be set invisible.

Logic for checking empty columns

u define one structure with flags. for each column in the data table u have to define one flag in the structure.

suppose my table is having columns A B C

then i will define structure

types begin of str_flags,

A_f type c ,

B_f type c,

C_f type c,

end of str_flags.

loop on the internal table and check each column whether it is empty or not

if it is not empty set the flag as 'X'.

finally after the end of loop u will come to know which columns r empty.

Regards,

janakiram.

Former Member
0 Kudos

Hi Ritwik,

how to hide a column:

DATA: lr_column TYPE REF TO cl_salv_wd_column,

lr_column_settings TYPE REF TO if_salv_wd_column_settings,

lv_set_column_visible TYPE wdy_uie_library_enum_type,

lr_salv_wd_conf_table TYPE REF TO CL_SALV_WD_CONFIG_TABLE,

lr_alv_site_view_ci TYPE REF TO IWCI_SALV_WD_TABLE.

lr_alv_site_view_ci = wd_this->wd_cpifc_alv( ).

lr_salv_wd_conf_table = lr_alv_site_view_ci->get_model( ).

lr_column_settings ?= lr_salv_wd_conf_table.

lr_column = lr_column_settings->get_column( 'COLUMN_NAME' ).

lv_set_column_visible = cl_wd_uielement=>e_visible-none.

lr_column->set_visible( lv_set_column_visible ).

Please note, that in the WD component, in the component usage, my SALV_WD_TABLE component is called simply 'ALV' in my component, you need to change this coding above according to your settings.

how to find empty column:

the easiest way, if you loop through the table behind the ALV and check, whether the column is empty.

BR,

Peter.