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: 

SORT problem!!

Former Member
0 Kudos
101

I don't know..might be simple problem...

DATA : BEGIN OF i_cdpos OCCURS 0.

INCLUDE STRUCTURE cdpos.

DATA : udate LIKE cdhdr-udate.

DATA : utime LIKE cdhdr-utime.

DATA : END OF i_cdpos.

i_cdpos-objectid = '0000050211'.

i_cdpos-value_new = '20070329'.

i_cdpos-value_old = '20021021'.

i_cdpos-udate = '20070518'.

i_cdpos-utime = '102421'.

APPEND i_cdpos.

i_cdpos-objectid = '0000050211'.

i_cdpos-value_new = '20070330'.

i_cdpos-value_old = '20070329'.

i_cdpos-udate = '20080103'.

i_cdpos-utime = '123617'.

APPEND i_cdpos.

SORT i_cdpos BY udate utime.

Here I'm trying to sort above table by UDATE. I've tried with ASCENDING and DESCENDING keywords as well... But always I'm getting 20070518 (udate) as first record in itab. Any one have any clue to keep 20080103 (udate) as first record in my itab.

1 ACCEPTED SOLUTION

ThomasZloch
Active Contributor
0 Kudos
73

hmmm, did you really put the DESCENDING inbetween UDATE and UTIME?

as in

SORT i_cdpos BY udate DESCENDING utime.

5 REPLIES 5

Former Member
0 Kudos
73

Hello,

Make this change.

SORT I_CDPOS BY UDATE DESCENDING.

Cheers,

Vasanth

ThomasZloch
Active Contributor
0 Kudos
74

hmmm, did you really put the DESCENDING inbetween UDATE and UTIME?

as in

SORT i_cdpos BY udate DESCENDING utime.

0 Kudos
73

you are right tom,

I'm trying like this...

SORT i_cdpos BY udate utime DESCENDING.

Thanks Vasanth & ABAP technical

former_member191735
Active Contributor
0 Kudos
73

Following code will get you what you want.

DATA : BEGIN OF i_cdpos OCCURS 0.

INCLUDE STRUCTURE cdpos.

DATA : udate LIKE cdhdr-udate.

DATA : utime LIKE cdhdr-utime.

DATA : END OF i_cdpos.

i_cdpos-objectid = '0000050211'.

i_cdpos-value_new = '20070329'.

i_cdpos-value_old = '20021021'.

i_cdpos-udate = '20070518'.

i_cdpos-utime = '102421'.

APPEND i_cdpos.

i_cdpos-objectid = '0000050211'.

i_cdpos-value_new = '20070330'.

i_cdpos-value_old = '20070329'.

i_cdpos-udate = '20080103'.

i_cdpos-utime = '123617'.

APPEND i_cdpos.

SORT i_cdpos BY udate DESCENDING utime.

Former Member
0 Kudos
73

Use

SORT i_cdpos BY udate descending

It just worked for me

Lokesh