Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV - Sort Aggregation Column

Former Member
0 Likes
1,174

Hi,

I have the following scenario.

I sorted the column 'customer' and I am using CL_SALV_AGGREGATIONS to subtotal the records by 'customer'. When I sorted 'customer', 'customer' column will appearing in alphabetical order. For example,

Customer A 1 (this is the aggregation subtotal)

Customer B 4

Customer C 3

My question is, can I sort the ALV display by the subtotal from the aggregation? Meaning I want to display the 'customer' with the most record first, like this

Customer B 4

Customer C 3

Customer A 1

Thanks!

Cady

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
931

Hi

You can't sort on the Subtotal amount field

If needed use another non numeric field to sort

after the display anyhow using the MENU options you can sort that subtotal field and see

Regards

Anji

Message was edited by:

Anji Reddy Vangala

8 REPLIES 8
Read only

former_member194669
Active Contributor
0 Likes
931

Hi,

Try this way


data: gr_sorts      type ref to cl_salv_sorts.
....
....

gr_sorts = gr_table->get_sorts( ).
gr_sorts->add_sort( columnname = 'CUSTOMER' subtotal = abap_true ).

a®

Read only

0 Likes
931

Hi a®s,

Thanks for your suggestion but I want to show the subtotal.

Cheers,

Cady

Read only

0 Likes
931

Hi,

Try this way


gr_sorts->add_sort( columnname = 'CUSTOMER' subtotal = abap_true ).

aRs

Read only

0 Likes
931

Hi aRs ,

Yes that's what i did. In addition to that i want to sort the subtotal.

Thanks.

Cady

Read only

Former Member
0 Likes
931

Hi,

Instead of sorting based on Customer, sort it on Aggrigation value.

Regards,

Satish

Read only

0 Likes
931

Hi Satish,

I am not getting you here. How do i sort it on aggregation value? Perhaps I am not being clear enough. Basically, i have 3 columns in the alv. Column 1 = customer, column 2 = documents for customer, column 3 = an integer 1. I am sorting column customer and aggregate on column 3. I hope I am not confusing you.

Thanks.

Cady

Read only

Former Member
0 Likes
932

Hi

You can't sort on the Subtotal amount field

If needed use another non numeric field to sort

after the display anyhow using the MENU options you can sort that subtotal field and see

Regards

Anji

Message was edited by:

Anji Reddy Vangala

Read only

0 Likes
931

Hi Anji,

Nope, the menu option doesnt work. Subtotal disappear after sort. Is there a workaround for this?

Thanks.

Cady