Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Default sort order in the select statement

Greeting everyone.

I am analysing one of the ABAP programs in our sytem.

It seems to be producing different results in development and production system.

I understand that there will be data differences between these two systems. But, the sort order of the results returned by the select statements vary.

When the below SELECT statement is executed, in development system the result is sorted by the database table key FIELD1. But in production system, there is no sorting as far as I can see.

Is there some parameter or database setting that controls this.

How can we get the properly sorted results in our Production system.

Below is my select statement and the associated data declarations

TYPES: BEGIN OF ty_table1,

                 field2 like table1-field2,

                 field1 like table1-field1,

                 field3 like table1-field3,

                 field4 like table1-field4,

               END OF ty_table1.

DATA: i_table1 TYPE STANDARD TABLE OF ty_table1.


SELECT field2 field1 field3 field4

               FROM table1



                    field2 = '100191'.

The database table TABLE1, has the fields in order FIELD1-FIELD2-FIELD3-FIELD4. FIELD1 is the only key field.

Former Member
Former Member replied

Hi Joshva,

you should guarantee equal sort order by abap coding. I would not use it in the SQL-statement, since ORDER BY is decreasing performance.

Instead declare the internal table as sorted with unique key or you sort your internal standard table as desired by FIELD1 ascending or descending.


1 View this answer in context

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question