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

SORT problem!!

Former Member
0 Likes
756

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
Read only

ThomasZloch
Active Contributor
0 Likes
728

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

as in

SORT i_cdpos BY udate DESCENDING utime.

5 REPLIES 5
Read only

Former Member
0 Likes
728

Hello,

Make this change.

SORT I_CDPOS BY UDATE DESCENDING.

Cheers,

Vasanth

Read only

ThomasZloch
Active Contributor
0 Likes
729

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

as in

SORT i_cdpos BY udate DESCENDING utime.

Read only

0 Likes
728

you are right tom,

I'm trying like this...

SORT i_cdpos BY udate utime DESCENDING.

Thanks Vasanth & ABAP technical

Read only

former_member191735
Active Contributor
0 Likes
728

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.

Read only

Former Member
0 Likes
728

Use

SORT i_cdpos BY udate descending

It just worked for me

Lokesh