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: 

sorting

Former Member
0 Kudos

friends,

i have an internal table which has 10 rows....in that, i need to sort the 1st column and the 8th col ascending wise...both are numeric fields only, i.e.,

sort itab by sloc days...but it's not working..where am i going wrong? thanks all

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi,

Check out this way ..

sort ascending itab by sloc days.

Regards,

santosh

5 REPLIES 5

Former Member
0 Kudos

hi,

Check out this way ..

sort ascending itab by sloc days.

Regards,

santosh

eddy_declercq
Active Contributor

Former Member
0 Kudos

Hi,

one observation..

Do one thing just comment 2...7 fields in ur itab ..

and sort only 1 and 8 field ..

sort itab by 1(field).

now check the o/p ..

if it's correct as per ur expectations then some of the field from 2..7 is affecting the sort criteria..

im guessing this cause i dont know ur fields or itab structure .

regards,

Vijay

Message was edited by: Vijay

Former Member
0 Kudos

Satish,

SORT ITAB BY field1 field8.

The above should work...when you say it is not working can you describe the problem(with values) ?

Regards

Anurag

Former Member
0 Kudos

Satish,

sort ascending should work in this situation.

have a look at following code for some idea.

DATA: BEGIN OF t_t OCCURS 0,

v1(2) type n,

v2(2) type n,

v3(2) type n,

END OF t_t.

start-of-selection.

t_t-v1 = 10.

t_t-v2 = 10.

t_t-v3 = 10.

append t_t.

clear t_t.

t_t-v1 = 20.

t_t-v2 = 10.

t_t-v3 = 10.

append t_t.

clear t_t.

t_t-v1 = 30.

t_t-v2 = 20.

t_t-v3 = 10.

append t_t.

clear t_t.

t_t-v1 = 30.

t_t-v2 = 10.

t_t-v3 = 20.

append t_t.

clear t_t.

sort t_t ascending by v1 v3.

loop at t_t.

write:/ t_t-v1, space, t_t-v2, space, t_t-v3.

endloop.

-Anu