‎2011 Nov 10 8:23 AM
Hi experts.
I have some problem with my program.
When I sort an internal data, result is different depends on application server.
SORT ITAB BY STR1 STR2.
<APP1>
STR1 STR2 STR3 STR4 INT1
AAAAA BBBBB CCCC1 DDDD1 1
AAAAA BBBBB EEEE1 CCCC1 2
AAAAA BBBBB DDDD1 CCCC1 2
AAAAA BBBBB DDDD1 CCCC1 1
<APP2>
STR1 STR2 STR3 STR4 INT1
AAAAA BBBBB CCCC1 DDDD1 1
AAAAA BBBBB DDDD1 CCCC1 2
AAAAA BBBBB DDDD1 CCCC1 1
AAAAA BBBBB EEEE1 CCCC1 1
What can be the reason for this situation?
(any SAP/DB parameter? DB setting?)
*APP1 is oracle 10g and APP2 is oracle 11g System.
Thanks in advance.
‎2011 Nov 10 10:04 AM
Hello,
I agree with Vishnu, if you are interested in record positions of column STR3, include it in your sort key.
Regards
‎2011 Nov 10 8:30 AM
This has nothing to do with application server. Even within the same server the same table if it is sorted twice will show different order for records that are duplicated on the sort key fields, after each sorting. The order of records that are duplicated on the sort key is not guaranteed with normal SORT command.
There is STABLE addition to SORT statement which will guarantee you that the record order is maintained even if the records are duplicated on SORT keys.
Refer SAP documentation for SORT with STABLE addition. Though, STABLE edition makes the SORT slower
Refer this: http://help.sap.com/abapdocu_70/en/ABAPSORT_ITAB.htm#&ABAP_ADDITION_1@1@
‎2011 Nov 10 9:16 AM
Thank you for your reply.
But in this case, the sort result is always same on the same server.
So.. I`m thinking that the reason could be DB version or SAP/DB Parameter.
Is there any information about this?
‎2011 Nov 10 9:28 AM
In addition, the default LOCALE (language settings) of the application server can lead to differences in sorting.
Refer the last secton of SET LOCALE command, where this is explained: http://help.sap.com/abapdocu_70/en/ABAPSET_LOCALE.htm. So you can play around with SET LOCAL and force the LOCALE setting to one value on both the servers rather than letting them to default to possibly different values.
If you want your sorting to be more predictable may be you can consider using the other fields in the sort key so that the record positions are guaranteed?
‎2011 Nov 10 10:04 AM
Hello,
I agree with Vishnu, if you are interested in record positions of column STR3, include it in your sort key.
Regards