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

Internal Table sort order

Former Member
0 Likes
772

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
734

Hello,

I agree with Vishnu, if you are interested in record positions of column STR3, include it in your sort key.

Regards

4 REPLIES 4
Read only

Former Member
0 Likes
734

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@

Read only

0 Likes
734

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?

Read only

0 Likes
734

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?

Read only

Former Member
0 Likes
735

Hello,

I agree with Vishnu, if you are interested in record positions of column STR3, include it in your sort key.

Regards