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

Reverse Order

Former Member
0 Likes
387

Hi All,

Please tell me how to Copy records from itab1 {1,5,6,7} to itab2 {10,16,9,20} in reverse order.

Thanks,

Sri.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
372

Hi Sriram,

You can try something like this -

itab1 - 1 5 6 7.
sort itab descending - 7 6 5 1.
loop at itab1.
  append itab1 to itab2.
endloop.
itab2 - 10 16 9 20 7 6 5 1
sort itab1 asscending - 1 5 6 7

Regards,

Anand Mandalika.

2 REPLIES 2
Read only

Former Member
0 Likes
373

Hi Sriram,

You can try something like this -

itab1 - 1 5 6 7.
sort itab descending - 7 6 5 1.
loop at itab1.
  append itab1 to itab2.
endloop.
itab2 - 10 16 9 20 7 6 5 1
sort itab1 asscending - 1 5 6 7

Regards,

Anand Mandalika.

Read only

0 Likes
372

Or (if you don't want to sort).

describe table itab1 lines n.

n2 = n.

do n2 times.

read table itab 1 index n into wa_itab1.

append wa_itab1 to itab2.

n = n - 1.

enddo.

P.S. consider this psuedo code.