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 to sort internal table

Former Member
0 Kudos

Hi

How to sort internal by binary search...please don't suggest SORT TABLE or HASHED table to use...

7 REPLIES 7

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You can use a SORTED Table.

data: itab type sorted table of mara 
            with unique key MATNR.

Regards,

Rich Heilman

0 Kudos

can u suggest any other method????

0 Kudos

Well, the other way would be to use the SORT statement.

Regards,

Rich Heilman

0 Kudos

canu write code for it...

0 Kudos

hi,

Use SORT Statement....

i.e,

sort itab.




Here is the code

TYPES: BEGIN OF PERSON_TYPE,
NAME(10) TYPE C,
AGE TYPE I,
COUNTRY(3) TYPE C,
END OF PERSON_TYPE.

DATA: PERSON TYPE STANDARD TABLE OF PERSON_TYPE WITH
NON-UNIQUE DEFAULT KEY INITIAL SIZE 5,
WA_PERSON TYPE PERSON_TYPE.

WA_PERSON-NAME = 'Muller'. WA_PERSON-AGE = 22.
WA_PERSON-COUNTRY = 'USA'.
APPEND WA_PERSON TO PERSON.
WA_PERSON-NAME = 'Moller'. WA_PERSON-AGE = 25.
WA_PERSON-COUNTRY = 'FRG'.
APPEND WA_PERSON TO PERSON.
WA_PERSON-NAME = 'Möller'. WA_PERSON-AGE = 22.
WA_PERSON-COUNTRY = 'USA'.
APPEND WA_PERSON TO PERSON.
WA_PERSON-NAME = 'Miller'. WA_PERSON-AGE = 23.
WA_PERSON-COUNTRY = 'USA'.
APPEND WA_PERSON TO PERSON.

SORT PERSON.

SORT PERSON BY NAME AS TEXT

SORT PERSON DESCENDING BY COUNTRY AGE NAME.

SORT PERSON DESCENDING BY AGE ASCENDING NAME AS TEXT.

Reward if it helps,

Regards,

Santosh

Former Member
0 Kudos

data : t_marc type standard table of marc with header line.

sort t_marc by matnr werks.

0 Kudos

There are a lot of different ways to write a SORT statement. It really depends on how you want to sort.

Example.

sort ivbep by vbeln posnr ascending
              edatu descending.

Regards,

Rich Heilman