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

sorting

Former Member
0 Likes
719

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

Former Member
0 Likes
699

hi,

Check out this way ..

sort ascending itab by sloc days.

Regards,

santosh

5 REPLIES 5
Read only

Former Member
0 Likes
700

hi,

Check out this way ..

sort ascending itab by sloc days.

Regards,

santosh

Read only

eddy_declercq
Active Contributor
Read only

Former Member
0 Likes
699

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

Read only

Former Member
0 Likes
699

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

Read only

Former Member
0 Likes
699

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