cancel
Showing results for 
Search instead for 
Did you mean: 

Is there an ALV function similar to the TABLE Row grouping?

Former Member
0 Kudos

Hi,

I have a requirement that needs rowspaning and in an other thread somebody helped me to know that in a WDA TABLE you can use the Row grouping(found it as groupingValue when developing).

The question is if there is a similar function for ALV, or this can only be achieved in a TABLE.

Hope somebody knows the answer.

Kind Regards!

Gerardo J

Accepted Solutions (1)

Accepted Solutions (1)

arjun_thakur
Active Contributor
0 Kudos

Hi

Row grouping is possible in ALV Table as well:

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' ). "connid is the col name
  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

Former Member
0 Kudos

Hi Arjun,

Thanx for the quick response, I have a question, wont this alter the order of the table? I need to merge the rows but not to alter the order in which the table was sent to me.

Kind Regards and Thanx in advanced!

Gerardo J

arjun_thakur
Active Contributor
0 Kudos

Hi Gerardo,

I think in order to use set_grouping_allowed method, we have to first use the create_sort_rule method. By using this method values will be sorted which could change the order of the table. I don;t see any other way.

BTW, grouping would make more sense if all the similar values come together. For that sorting can be used.

Regards

Arjun

Former Member
0 Kudos

Thanx Alot Arjun,

it was really helpful, in my case the data in the table will be sent ordered in a way the rows can be toghether for doing the rowspaning and also we could have the case that 4 values in that column are the same and we need to group 3 of them in one rowspan and the other one just alone, so I think we could not use the ALV in that way to do the rowspaning for our case but your answers have been really helpful and I really apreciate it!

Kind Regards,

Gerardo J

Answers (0)