06-14-2011 12:17 PM
Hi All,
I have a question regarding key fields in SALVs
I have an internal table and would like to show the contents in an SALV.
The table is defined from a view that I have created.
When I display the SALV all the columns seem to be key columns so all the columns look 'highlight' for want of a better word.
Is there a way I can set all the columns so they are not viewed as keys, this would make reading the SALV output much easier and I could then for example used the set_striped_pattern method.
Also if I can do this will this acutally change the settings in the initial internal table of just in the SALV
Any help would be great.
Thanking you in advance
Ian
06-14-2011 12:35 PM
Explore the use of class method CL_SALV_COLUMN_TABLE->SET_KEY. There are enough information available in forums & wiki contents regarding different SALV functionalities.
Regards, Vinod
06-14-2011 12:35 PM
Explore the use of class method CL_SALV_COLUMN_TABLE->SET_KEY. There are enough information available in forums & wiki contents regarding different SALV functionalities.
Regards, Vinod
06-14-2011 12:52 PM
Hello Vinod,
I'm on release 701 & i don't see the method SET_KEY( ) in the class CL_SALV_COLUMN_TABLE!
BR,
Suhas
06-14-2011 12:56 PM
My bad, its in class CL_SALV_COLUMN_LIST. I tried this way.
DATA : lr_columns TYPE REF TO cl_salv_columns_table,
lt_col_list TYPE salv_t_column_ref,
ls_col_list TYPE salv_s_column_ref,
lr_column TYPE REF TO cl_salv_column_table.
lr_columns = lr_table->get_columns( ).
lt_col_list = lr_columns->get( ).
LOOP AT lt_col_list INTO ls_col_list.
TRY.
lr_column ?= lr_columns->get_column( columnname = ls_col_list-columnname ).
lr_column->set_key(
EXPORTING
value = ' ' ).
CATCH cx_salv_not_found .
ENDTRY.
ENDLOOP.
Regards, Vinod
06-14-2011 1:04 PM
Hello Vinod,
I was looking in the CL_SALV_COLUMNS_TABLE class
Sorry for the confusion!
Cheers,
Suhas
06-14-2011 1:05 PM
This is the code that worked for me.
DATA: lo_salv TYPE REF TO cl_salv_table,
lo_columns TYPE REF TO cl_salv_columns_table,
lo_column TYPE REF TO cl_salv_column_table,
lo_display_settings TYPE REF TO cl_salv_display_settings.
" END OF local data declaration
*&---------------------------------------------------------------------*
IF lo_salv IS INITIAL.
" No SALV object created then create the object.
TRY.
cl_salv_table=>factory( IMPORTING r_salv_table = lo_salv
CHANGING t_table = i_mrp_v_mdel ).
CATCH cx_salv_msg .
ENDTRY.
ENDIF. " No SALV object created then create the object.
lo_columns = lo_salv->get_columns( ). " Get columns from SALV
lo_column ?= lo_columns->get_column( 'MANDT' ). " Get the MANDT/Client column
lo_column->set_visible( C_FALSE ). " And make it invisible
lo_column ?= lo_columns->get_column( 'EKORG' ). " Get the EKO column
lo_column->set_key( C_FALSE ). " And make it a 'normal' column
Regards
Ian