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,

Chaitanya.

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( ).
      ENDIF.
    
     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.

    Regards

    Arjun

    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.

      Regards

      Arjun

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

    Hi,

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

    cl_salv_table

    http://help.sap.com/saphelp_nw04/helpdata/en/10/e4eb40c4f8712ae10000000a155106/content.htm

    Best Regards

    Ravi

    Add comment
    10|10000 characters needed characters exceeded