cancel
Showing results for 
Search instead for 
Did you mean: 

FOR ALL ENTRIES sorted.

Former Member
0 Kudos

Hi all,

The resulting list is not necessarily sorted even if the FOR ALL ENTRIES itab is sorted. How can make sure the optimizer will process the FOR ALL ENTRIES in the itab's sorted order?

For example, I would like to get the 10 most recently created sales orders:

sort itab by vbeln descending.
select bstnk up to 10 rows
  from vbak
  into table itab_bstnk
   for all entries in itab
  where vbeln = itab-vbeln.

Would declaring the itab as a sorted internal table help? Any ideas?

Thanks a lot,

John

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

By the way, ORDER BY clause cannot be used with FOR ALL ENTRIES that is why I am asking (exception is SELECT *--- FOR ALL ENTRIES --- ORDER BY PRIMARY KEYS).

Any ideas?