‎2012 Oct 18 12:20 PM
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.
‎2012 Oct 18 12:43 PM
I tried to find the significant difference and gave up. Where is it?
Thomas
‎2012 Oct 18 12:59 PM
I Thomas,
You can find the différence after the yellow column.
thanks for your help.
‎2012 Oct 18 1:09 PM
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
‎2012 Oct 18 1:10 PM
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
‎2012 Oct 18 1:25 PM
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.
‎2012 Oct 18 1:52 PM
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