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: 

How sort internal table with punctuation on non unicode system?

Former Member
0 Kudos

Hi

We have a system with NON UNICODE. I would like sort internal table using Sort method.

When I use:

Sort itab By nachn Ascending. ""system sort by not with puntuation

e.g. when I have A, C, Č, B, Z,

System sort like that:

A, B, C, Z, Č,

But correct is:

A, B, C, Č, Z,

Thank you

1 ACCEPTED SOLUTION

Tomas_Buryanek
Active Contributor

Try addition SORT ... AS TEXT. It works for me, but it depends on "locale text environment" (ABAP keyword documentation for more details):


  • Character-like components are sorted by default by their binary representation (code page). Textual sorting of character-like components can be performed using the addition AS TEXT.
-- Tomas --
7 REPLIES 7

former_member1716
Active Contributor
0 Kudos

Hi,

I would suggest you to convert the UNICODE to ASCII values and then try to sort. Hope this will work.

Regards,

Satish

former_member1716
Active Contributor
0 Kudos

This FM  URL_ASCII_CODE_GET Will give you the ASCII value for any character.

Regards,

Satish

0 Kudos

Hi

Thank you for your answer.

When I check FM URL_ASCII_CODE_GET and I put char I give this result.

A = 41

C = 43

Č = C8

Z = 5A

B = 42

When I sort by Ascii value, still I get wrong result, because Č(C8) is greater like Z(5A).

Or I doing something wrong?

Thank you

0 Kudos

Why dont you try to convert the character to Binary and then sort.

0 Kudos

Hi

When I use SORT "AS TEXT", this works.

Thank you

Tomas_Buryanek
Active Contributor

Try addition SORT ... AS TEXT. It works for me, but it depends on "locale text environment" (ABAP keyword documentation for more details):


  • Character-like components are sorted by default by their binary representation (code page). Textual sorting of character-like components can be performed using the addition AS TEXT.
-- Tomas --

0 Kudos

Hi

Thank for you answer. I have a mistake in Sort sxpression.

SORT itab BY NACHN VORNA ASCENDING AS TEXT ICON ASCENDING. ""sort not correctly

SORT itab BY NACHN ASCENDING AS TEXT VORNA ASCENDING AS TEXT ICON ASCENDING. ""sort correctly

Thank you