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

Simple question about ALV sorting

Former Member
0 Likes
922

I retrieve data from SFLIGHT table and display it in ALV by using cl_salv_table class. I added a sorting column PRICE as follows:


 data r_salv_sort type ref to cl_salv_sorts.
 r_salv_sort = r_salv_table->get_sorts( ).
 r_salv_sort->add_sort('PRICE').

and got exception message:

Subtotals cannot be calculated on aggregatable columns

it is fine when I change from PRICE column to CONNID column.

What could be the reason for that? I just want to sort the Price column. Thanks!

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
0 Likes
837

Check this discussion on SORT for Numeric Column:

Regards,

Naimesh Patel

6 REPLIES 6
Read only

naimesh_patel
Active Contributor
0 Likes
838

Check this discussion on SORT for Numeric Column:

Regards,

Naimesh Patel

Read only

0 Likes
837

Hi,

I read the thread and it is a workaround, not a solution by the way. Move the numeric column to another non-numeric column, sort it and hide the numeric column.

I still can do the sorting via user interface by right click on the numeric column. So is there anyway to do that in code? thanks!

Best regards,

Anthony

Read only

0 Likes
837

We can do the sorting on the Quantity or Amount column once it ALV is displayed. Because now the control is no more with the SALV model. It is with the ALV framework.

SALV model doesn't allow the sorting on the columns on which you can perform the Agreegation.

You can save the default layout variant and then start the ALV with that variant.

Regards,

Naimesh Patel

Read only

Former Member
0 Likes
837

HI,

Sort cannot be performed on the quantity,float and currency fields on which aggregate Function applies.

Read only

Former Member
0 Likes
837

I agree to the point mentioned by avinash !

What you can do is create a field with char attributes and assign the price value to it.

Now to sort the table you can use this field.

While displayin in ALV you can hide this field.

or

You can always use sort option after the output.

Regards,

Lalit Mohan Gupta.

Read only

Former Member
0 Likes
837

Thanks all for your helps!