Application Development 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: 

Alphanumeric sorting

debanjan48
Explorer
0 Kudos

How does ABAP handle sorting on alphanumeric column ?

12 REPLIES 12

Tomas_Buryanek
Active Contributor

SELECT ORDER or "ABAP" (ITAB) sort? Both are described in ABAP documentation...

-- Tomas --

Sandra_Rossi
Active Contributor

I would answer "as any other programming language". Can you explain what is your doubt?

Jelena
Active Contributor
0 Kudos

Gently. 🙂 I'm also curious what exactly is the concern here.

matt
Active Contributor

It sorts it alphanumerically.

raymond_giuseppi
Active Contributor

Character-like columns are sorted by default by their binary representation, encoding in the code page of the current text environment.

You can force a 'textual' sort using option AS TEXT to use locale text environment, which depends on Language, Operating System and Kernel (e.g. rules fo upper/lower case or accented characters, or characters that don't belong to the language...) Can you guess performance impact of this option...

debanjan48
Explorer
0 Kudos

My question is how are alphanumeric data sorted. For example:

ABC1234

ABC7865

ABC0859

ABB9999

90

ANHYT

How will the above get sorted ?

raymond_giuseppi
Active Contributor
0 Kudos

Result will be different in a UNICODE or ASCII system vs an EBCDIC system, why didn't you try with a simple report (check online documentation for such program, look for 'Executable Examples')

matt
Active Contributor
0 Kudos

It will sort

  • ABC1234
  • ABC7865
  • ABC0859
  • ABB9999
  • 90
  • ANHYT

alphanumerically. It seems you don't know what "alphanumerically" means, so I suggest you write a short program and find out exactly how this data will be sorted on your system..

0 Kudos

Hi Matthew,

I guess alphanumeric means a combination of characters and numeric data. Can you please explain the reason for keeping 90 in between after sorting and not at the either extreme ends i.e. top or down.

Regards,

Debanjan Das

matt
Active Contributor
0 Kudos

I have just written a program, as I suggested you did, that takes those values in and sorts them. The '90' record comes at one of the extreme ends. It does not come in between. Why do you think it does?

Sandra_Rossi
Active Contributor

Raymond Giuseppi as far as I can see in the documentation, with Unicode systems, SORT without AS TEXT doesn't depend anymore on the code page but only on the Unicode code point, and SORT with AS TEXT depends on the locale (based on the logon language or the one set by SET LOCALE).

Debanjan Das Concerning SORT with AS TEXT, for example the locales for languages Serbian, Chinese and Thaï, have characters sequenced as follows, here from the 4900th position; both the glyph and its Unicode code point are represented; it's done by a custom program:

SAP online example gives this result (1st sorting is based on the Unicode code points, 2nd and 3rd on the order of characters in the current locale):

DoanManhQuynh
Active Contributor
0 Kudos

so in general, the alphanumeric would be understood by computer in term of sequence of 2 bit 0 & 1. then sort is compare those sequence.