Skip to Content
2
Jan 09, 2023 at 09:28 AM

SORT and GROUP BY

697 Views

Imagine a source code like this where we first sort an internal table and directly after that group by:

SORT lt_data_aqua BY lgtyp lgber.
LOOP AT lt_data_aqua ASSIGNING FIELD-SYMBOL(<ls_data_aqua>)
GROUP BY <ls_data_aqua>-lgber ASSIGNING FIELD-SYMBOL(<lg_aqua_lgber>).
[...]
ENDLOOP.

In this case we sort by storage type and storage section and then group by storage section. The sorting algorithm of GROUP BY wouldn't have to sort the internal table by storage type and section as we already did this by SORT previously.

Does the SORT have a positive impact on performance on the following GROUP BY statement by presorting the related internal table?

Many thanks in advance for your help!