Skip to Content
author's profile photo Former Member
Former Member

How is buffer data sorted in FOX FOREACH-loop?

Hi everybody,

I would appreciate some help on the following.

I need to create a historical mean by time period by company code. The number of historical data points is unknown.

A loop "FOREACH co-co 0FISCPER..." will sort the buffer data by co-co and 0FISCPER. My question refers to the sort logic of this data.

I have noticed that the loop:

processes the co-co's in a ascending order (by technical key) going through the FISCPERs from the oldest to the most recent.


FOREACH iteration

1: co-co 4711 fiscper 1.2005

2: co-co 4711 fiscper 2.2005

3: co-co 4711 fiscper 3.2005

4: co-co 4712 fiscper 1.2005

5: co-co 4712 fiscper 2.2005

6. etc.

Can I rely on that this will always be the case?

Or could it be that the sort order sometime is ascending and sometime is descending? In which case the above example could look like this (if co-co is ascending and FISCPER descending).

1: co-co 4711 fiscper 3.2005

2: co-co 4711 fiscper 2.2005

3: co-co 4711 fiscper 1.2005

4: co-co 4712 fiscper 2.2005

5: co-co 4712 fiscper 1.2005

6. etc.

I saw some documentation on this sometime back, but have been unable to find it again. Does anyone know where this sorting logic is documented? Thanks for any help.


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Oct 16, 2005 at 04:19 AM

    Hello Martin,

    the combinations for the foreach loop at stored in an internal table and then sorted using the ABAP sort statement. So yes, the values are sorted in ascending order based on the internal value of the characteristics (YYYYMMM for fiscal period).



    SAP NetWeaver RIG

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.