Application Development and Automation 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: 
Read only

Sort difference between environment

Former Member
0 Likes
1,188

Hi expert,

This question is for my comprehension.

In different environnement I have different reaction on the sort function you can see in the attached file the information needed.

The sort is not the same between the environment can you explain to me why?

Sort declaration :

Sort i_plopo by plnty plnnr

Environment : Prod

Before sort

After sort

Environment : Pre-prod

Before sort

 

After sort

So could you please explain why this difference after sort execution.

Thanks and regards.

6 REPLIES 6
Read only

ThomasZloch
Active Contributor
0 Likes
1,123

I tried to find the significant difference and gave up. Where is it?

Thomas

Read only

0 Likes
1,123

I Thomas,

You can find the différence after the yellow column.

thanks for your help.

Read only

0 Likes
1,123

You are only sorting by PLNTY and PLNNR, so the rest is undefined. The sequence comes probably from a preceding SELECT statement, which again is undefined in relational databases if not defined explicitely e.g. via ORDER BY.

Better include all relevant colums in the SORT statement for reliable results.

Thomas

Read only

Former Member
0 Likes
1,123

Hi,

I guess what you means by difference is the order of PLNKN change after you sort it according to PLNNR, to keep the original order of PLNKN, you may perform STABLE SORT(e.g: SORT internal_table  STABLE BY plnnr).

You may study the link below for more information about stable sort:

http://help.sap.com/saphelp_erp60_sp/helpdata/en/fc/eb3800358411d1829f0000e829fbfe/content.htm

Regards,

Xavier

Read only

Former Member
0 Likes
1,123

HI,

Thanks for your reply.

But I understandant what you say but how can I explain it?

The select return the data in the same order and after ther sort command the data haven't got the same issue.

This program was edited by another consultant. He should sort the table by defining the column PLNKN but he's missing it and now we have a difference between the environment due to the sort command.

My question is more: "why the sort is not the same between the two environment?" more data in production? is it a dynamic sort switch the size of the volumetry?

Thanks for your help.

Read only

0 Likes
1,123

Hi,

If I'm no mistaken ABAP using QuickSort(http://en.wikipedia.org/wiki/Quicksort) for their sorting algorithm,it pick random "pivot" to run the QuickSort and that's the reason why you saw different result from different server. Note that it only sort according to the column you specify and it doesn't care about the relative sequence of line by other columns.

Regards,

Xavier