cancel
Showing results for 
Search instead for 
Did you mean: 

How to change order of columns in wdp alv table

santhosh_nagavalli
Participant
0 Kudos

Hi Experts,

     Can anybody tell me how to change the order of columns in webdynpro alv table ,i have tried following code ,but this hav'nt worked,Please

let me know is there any other way ........advance thanks

CALL METHOD lo_value->if_salv_wd_column_settings~get_columns

    RECEIVING

      value = lt_columns.

* Get reference to each column and set the column position

  LOOP AT lt_columns INTO ls_column.

    lo_column = ls_column-r_column.

    CASE ls_column-id.

      WHEN 'VBELN'.

        lo_column->set_position('1' ).

      WHEN 'MATKL'.

        lo_column->set_position('2' ).

      WHEN 'POSNR'.

        lo_column->set_position('3' ).

      WHEN 'MATNR'.

        lo_column->set_position('4' ).

    ENDCASE.

  ENDLOOP.

ENDMETHOD.

Regards

Sandesh

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Hi Sandesh,

When we use the SALV_WD_TABLE component to display ALV, by default, all columns are arranged in the same order as the attributes in the context node of your
application.

You need to add the following code in the wddomodifyview( ) method of your View.

METHOD wddomodifyview

data:lt_columns type salv_wd_t_column_ref,

        ls_column  type salv_wd_s_column_ref,

        lo_column  type ref to cl_salv_wd_column ,

        lo_ref_cmp_usage  type ref to if_wd_component_usage,

       lo_ref_interfacecontroller type ref to iwci_salv_wd_table ,

       lo_value type ref to cl_salv_wd_config_table.

* Get  reference to the Component usage of the ALV.

lo_ref_cmp_usage = wd_this->wd_cpuse_alv( ).

IF lo_ref_cmp_usage->has_active_component( ) IS INITIAL.

 

lo_ref_cmp_usage->create_component( ).

ENDIF.

* Get reference to the Interface controller of the ALV.

lo_ref_interfacecontroller= wd_this->wd_cpifc_alv( ).

lo_value = lo_ref_interfacecontroller->get_model( ).

* Get the Columns of the ALV

CALL METHOD lo_value->if_salv_wd_column_settings~get_columns

  RECEIVING

value = lt_columns.

* Get reference to each column and set the column position

LOOP AT lt_columns INTO ls_column.

 

lo_column = ls_column-r_column.

CASE ls_column-id.

WHEN 'VBELN'.

lo_column->set_position('1').

WHEN 'MATKL'.

lo_column->set_position('2').

WHEN 'POSNR'.

lo_column->set_position('3').

WHEN 'MATNR'.

lo_column->set_position('4').

ENDCASE.

ENDLOOP.

ENDMETHOD.

Hope this helps you to resolve your issue.

Thanks

KH

Answers (1)

Answers (1)

ramakrishnappa
Active Contributor
0 Kudos

Hi Sandesh,

Your code should work fine.

What is the behavior of the alv table upon application run? is anything changed in the order of columns.

Regards,

Rama

santhosh_nagavalli
Participant
0 Kudos

Hi Ramakrishnappa ,

   Thanks for your reply,the columns are not changing in the table acoording to the order i specifies,and even i added a extra field in the table it also not displaying instead when Iam going to settings in table it is displaying in hidden columns, I have updated the Node also.with added attribute.

Regards,

Sandesh

former_member193460
Contributor
0 Kudos

Hi Sandesh,

     Try removing the literal.

lo_column->set_postition( 1 ) and so on.

Thanks & Regards,

Tashi

ramakrishnappa
Active Contributor
0 Kudos

Hi Sandesh,

I suspect, the user settings for the alv layout is set. Hence you need to reset the user settings.

Please refer my answer in the below thread.

Regards,

Rama