Application Development 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: 

Sort sequence

former_member182337
Participant
0 Kudos

Hello,

I have an internal table and am trying to sort the table by three fields. The internal table contains some 400 records and all the three fields that are used in the sort have same values for all the 400 records. I am expecting that the internal table ignore the sort and maintain the order of the 400 records ( 1 - 400 ) but instead it simply reverses the contents i.e after sort the internal table holds values from 400 - 1.

This is not my custom code and it is in one of the standard program of SAP. I am just wondering why the sort gets reversed irrespective of the fact that all the three fields specified in the sort has same values for all the 400 rows. Can some one throw some light?

Thanks.

Prem

3 REPLIES 3

former_member203305
Active Contributor
0 Kudos

Hi.

need to check the code, maybe it has some additional to the sort, such as descending or ascending.

Regards

Miguel

0 Kudos

Hi,

There is nothing mentioned in the same. It is simply sort ( internal table ) by field 1 , field 10 , field 14.

There are fields in between the sort fields i.e the table is sorted by field1, field 10 and field 14. If all these fields are the same would the system consider a different sort sequence i.e Field 2 , field 3 etc.I am really not sure how the internal table gets sorted in this condition.

matt
Active Contributor
0 Kudos

If you read the F1 help on SORT, you will see that has the optional addition STABLE. Without this, the order of records may change where records have identical keys.

"Without the STABLE addition, the order is not stable and multiple sorting of a table using the same sort key can result in a different order each time the table is sorted. "