Skip to Content
avatar image
Former Member

Grouping a column on display in ALV

Hi All,

Could some one help me on how to group similar values in an alv column when it is displayed for the first time itself, i know we can set/reset this functionality on sort by using the ~set_grouping_allowed method of the interface if_salv_wd_sort but i would like to group on first display itself.

I Apologise if the question was already posted.

Thanks In Advance,


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Mar 09, 2009 at 07:05 AM

    Hi Chaitanya,

    Please refer the following code:

     DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
      l_ref_cmp_usage =   wd_this->wd_cpuse_alv_first( ). " alv_first is the name of my alv component
      IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
        l_ref_cmp_usage->create_component( ).
     DATA l_salv_wd_table TYPE REF TO iwci_salv_wd_table.
      l_salv_wd_table = wd_this->wd_cpifc_alv_first( ).
      DATA: lr_field TYPE REF TO cl_salv_wd_field.
      DATA lo_config_model TYPE REF TO cl_salv_wd_config_table.
      lo_config_model = l_salv_wd_table->get_model( ).
      lo_config_model->if_salv_wd_table_settings~set_multi_column_sort( value = abap_true ).
      lr_field = lo_config_model->if_salv_wd_field_settings~get_field( 'CONNID' ).
      lr_field->if_salv_wd_sort~create_sort_rule( sort_order = if_salv_wd_c_sort=>sort_order_descending ).
      lr_field->if_salv_wd_sort~set_grouping_allowed( value = abap_true ).

    I hope it helps.



    Add comment
    10|10000 characters needed characters exceeded

    • Hi Chaitanya,

      For grouping to happen, we have to sort the column and for that we have to create the sort rule. Even if we don't pass the sort _order in the code, the column will get sorted in ascending order by default.



  • avatar image
    Former Member
    Mar 09, 2009 at 09:28 AM


    By using the below class properties you can do what ever action you require.


    Best Regards


    Add comment
    10|10000 characters needed characters exceeded