Skip to Content

Sort Sequence on Linux

Did you know, that the sorting order on Linux differs from that on HP-UX or Windows? Imagine that you have SAP Application Servers running on a heterogeneous system environment. When you display an ABAP list on an Application Server running on Linux the sorting of this list differs compared when displaying it on an Application Server running on HP-UX. This blog give you some background information, why the sorting is different and what these differences are. We’ll close it with some suggestions, how to solve this fuzziness.

How does the SAP system define the sort sequence?

There are basically two different methods, how the SAP system gets the information about the sort sequence. One method is used on Non-Unicode systems, the other one on Unicode systems. Having a Non-Unicode system, the SAP system get the sort sequence information from the locale provided by the operating system.  Whereas having a Unicode system, the sorting sequence is defined using the ICU (International Components for Unicode) definition which comes with the SAP system.

Non-Unicode

As already mentioned, Non-Unicode systems get the sort sequence directly from the locale, which comes with the operating system. The locales which are used are stored in SAP table TCP0C. The locale names on Unix operating systems are normally the same, but their sort sequence differs! I’ll give you an example. I have a file with the following content:

Original text:

Z_SAPTEST
Z:ABC
ZAA_TESTS
ZZSAPTOP
ZSAPGAME
ZAAALLOW
ZAA:ALLOW
ZSDTEST

Having HP-UX 11, the sorting looks like:

Z:ABC
ZAA:ALLOW
ZAAALLOW
ZAA_TESTS
ZSAPGAME
ZSDTEST
ZZSAPTOP
Z_SAPTEST

Whereas on Linux (SLES10) the sorting is:

ZAAALLOW
ZAA:ALLOW
ZAA_TESTS
Z:ABC
ZSAPGAME
Z_SAPTEST
ZSDTEST
ZZSAPTOP

It seems, that Linux ignores special characters like colon or underscore. HP-UX does have a ranking for these special characters. If you are used to the sort sequence of HP-UX it would really be hard to navigate through large lists generated on a Application Server on Linux. The entries you search for, are not at the position you expect them.

A solution for this unwanted behavior is available for both Novell SUSE Linux Enterprise Server and Red Hat Enterprise Linux. You need adapted locales, which implement a new sorting order. For more information, please have a look at SAP Note 1069443 how you can obtain these locales for your SUSE or Red Hat system.

Unicode

Having a Unicode system, makes life pretty much easier for you. As Unicode systems use the ICU sort sequence (which is part of the SAP kernel), it doesn’t matter on which platform you display your text or lists. They are sorted always correctly! 

Conclusion

As you face these problems only on Non-Unicode systems, it’s obvious that moving to Unicode is the only option that provides a consistent state of sorting. I’m not sure if the sorting between AIX, Solaris, HP-UX, Tru64 or Windows is always the same. We are lucky that the Linux distributors provide extra packages for Linux, but in general I strongly encourage you to move to Unicode.

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. RSCL Mumbai
    You are right about solaris and windows. I have faced these problems earlier with solaris and windows and was looking at HP-UX as a probable solution. But since you have done the r’n’d for me, makes life easier for me. Thank you.
    Call center outsourcing
    (0) 
    1. Hannes Kuehnemund Post author
      I checked the sort sequence (using the example from above) on Solaris. Thats the result:


      Z_SAPTEST
      Z:ABC
      ZAA_TESTS
      ZZSAPTOP
      ZSAPGAME
      ZAAALLOW
      ZAA:ALLOW
      ZSDTEST

      As expected, Solaris also differs from Linux and HP-UX!

      (0) 

Leave a Reply