on 12-21-2009 5:03 PM
Hi
Is there a way to change the sequence of the columns of an ALV in the WDDOMODIFYVIEW method?
REgards
Ian
You can directly specify the sequence of columns in the WDDOINIT method of view which embeds the Viewcontainer for ALV. (rather write a seperate method for this & call it in WDDOINIT to keep it structured/modular)
You can place this in WDDOMODIFYVIEW also but put conditions so that it doesnt get triggered all the time un-necesarily & impact performance.
get ALV/ model
IF lr_cmp_usage->has_active_component( ) IS INITIAL.
lr_cmp_usage->create_component( ).
ENDIF.
lr_com_controller_if = wd_this->wd_cpifc_alv( ).
lr_alv_config = lr_com_controller_if->get_model( ).
" -
start of code for position----
get column
lr_alv_column = lr_alv_config->if_salv_wd_column_settings~get_column( 'Z_NAME' ). " Column attribute name Z_NAME
set position
CALL METHOD lr_alv_column->set_position
EXPORTING
value = 1.
"--
Repeat this for rest of columns to specify positions( value = 2 , 3 , 4 and so on ) as required by you.
Thanks,
Phani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks to you both for your suggestions. I used the following to achieve what I wanted:
check first_time = abap_true.
data: lr_salv_wd_table type ref to iwci_salv_wd_table,
r_table type ref to cl_salv_wd_config_table,
r_functions type salv_wd_t_function_std_ref.
get reference to ALV component interface
lr_salv_wd_table = wd_this->wd_cpifc_alv( ).
get ConfigurationModel from ALV Component
r_table = lr_salv_wd_table->get_model( ).
Remove the Print button
r_table->if_salv_wd_std_functions~set_pdf_allowed( abap_false ).
init ColumnSettings
data: lr_column_settings type ref to if_salv_wd_column_settings,
lr_col_header type ref to cl_salv_wd_column_header.
data: lt_columns type salv_wd_t_column_ref.
data: ls_column type salv_wd_s_column_ref,
ls_tooltip type string.
lr_column_settings ?= r_table.
get table of column settings - each line one column
lt_columns = lr_column_settings->get_columns( ).
define visible columns (fields) by naming them,
exclude others by setting visibility to none
loop at lt_columns into ls_column.
" get header of column
lr_col_header = ls_column-r_column->get_header( ).
Switch the DDIC texts to Medium
lr_col_header->set_prop_ddic_binding_field(
property = if_salv_wd_c_ddic_binding=>bind_prop_text
value = if_salv_wd_c_ddic_binding=>ddic_bind_none ).
case ls_column-id.
when 'OTEXT'.
ls_column-r_column->set_position( '00' ).
1) get list of columns
2) loop at each column
3) set column position
code goes like this
DATA: lo_cmp_usage TYPE ref to if_wd_component_usage.
DATA: lr_salv_wd_table TYPE REF TO iwci_salv_wd_table.
DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lr_column TYPE REF TO cl_salv_wd_column,
lt_column TYPE salv_wd_t_column_ref,
ls_column TYPE salv_wd_s_column_ref.
DATA: lr_function_settings TYPE REF TO CL_SALV_WD_CONFIG_TABLE.
*create an instance of ALV component
lo_cmp_usage = wd_this->wd_cpuse_MY_ALV( ).
* if not initialized, then initialize
if lo_cmp_usage->has_active_component( ) is initial.
lo_cmp_usage->create_component( ).
endif.
* get ALV component
lr_salv_wd_table = wd_this->wd_cpifc_MY_ALV( ).
lr_function_settings = lr_salv_wd_table->get_model( ).
* get reference to column settings
lr_column_settings ?= lr_function_settings.
* get all columns
lt_column = lr_column_settings->get_columns( ).
* loop at columns
loop at lt_column into ls_column.
CASE ls_column-id.
when 'PRICE'.
* for PRICE
ls_column->set_position( value = '01' ). " and so on
endcase.
hope this helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Without writing any code in Modify view you can make the changes by
logining into administrative mode of the application and using settings of ALV table you can change the column sequence so that it is applicable for all users.
Priya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.