Grouping unsorted rows in an ALV

2.6k views Asked by At

Is it possible to automatically group rows on unsorted fields in an ALV? Suppose for instance that I have the following output:

1   T_PM1   0271    6025984     1271    602721
1   T_PM1   0271    6025984     1765    602721
1   T_PM1   0271    6025984     764     602721
1   T_PM1   0271    6025984     1242    602721
1   T_PM1   0271    6025984     1243    602721
1   T_PM1   0271    6025984     484     602721

Suppose I now sort on the first two columns and on the 5th. The first two columns will group to 1 and T_PM1 while the fifth will be sorted. However, the third, fourth and sixth columns all contain data that is derived from the first two columns and which is thus identical. How should I now force a grouping on these fields? (Note that I'm using the OO method of creating an ALV.)

The obvious solution would be to sort these columns as well but while I can't immediately think of a scenario where this would cause a bad sort, I am concerned that this makes my code less readable by inserting useless sorts and that these sorts will introduce unnecessary overhead by requiring an additional single pass through the data for every additional column to verify that it's already sorted.

1

There are 1 answers

1
vwegert On BEST ANSWER

As far as I know, it is not possible to group values in the ALV Grid in unsorted columns. Be aware that sorting will be performed by the ALV grid, so adding the columns to your SORT statement should be completely unnecessary - in fact, the entire SORT statement should not be necessary.

The number of columns that are used to sort a table usually only have a small influence on the total sorting time - most of the time, you won't have to worry about this.