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

Alphanumeric sorting

debanjan48
Explorer
0 Likes
4,909

How does ABAP handle sorting on alphanumeric column ?

12 REPLIES 12
Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
4,387

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

-- Tomas --
Read only

Sandra_Rossi
Active Contributor
4,387

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

Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
4,387

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

Read only

matt
Active Contributor
4,387

It sorts it alphanumerically.

Read only

RaymondGiuseppi
Active Contributor
4,387

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...

Read only

debanjan48
Explorer
0 Likes
4,387

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

ABC1234

ABC7865

ABC0859

ABB9999

90

ANHYT

How will the above get sorted ?

Read only

RaymondGiuseppi
Active Contributor
0 Likes
4,387

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')

Read only

matt
Active Contributor
0 Likes
4,387

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..

Read only

0 Likes
4,387

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

Read only

matt
Active Contributor
0 Likes
4,387

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?

Read only

Sandra_Rossi
Active Contributor
4,387

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):

Read only

DoanManhQuynh
Active Contributor
0 Likes
4,387

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.