02-03-2015 11:45 AM
Dear ,
I have one internal table, which have 5 field: A B C D E, and this internal table have many data. Now I want to change this internal table as this: still have 5 field, but it's sort is : A E D B C, and also move the data into the right place.
such as: A B C D E A E D B C
1 2 3 4 5 1 5 4 2 3
How to realize this function ?
Thanks for your sincerely answer!
02-03-2015 11:53 AM
Hi Zhang,
I am unable to understand your issue. You want to move your data from 1 internal table to other internal table?
If so, use MOVE-Corresponding and make sure internal table field name are same.
If this is not your question. Then please explain your requirement.
02-03-2015 11:55 AM
Hi,
you can loop the first internal table.
Loop at itab1.
move-coressponding itab1 to itab2.
append itab2.
endloop.
i suppose you mean moving the data from one internal table to other with same field but in different order.
Regards-
Makarand
02-03-2015 12:24 PM
Hi,
first, why do you want to do that? Is it for displaying? Then using a special layout variant would probably be a better solution.
If you really want to tansfer the content of table1 to table2, then you have to do a loop at table1, write the content of the current line to a line with the type of table2 and append this line to table2.
If the columns of your tables are named the same, than you can use the MOVE-CORRESPONDING statement. Otherwise you have to transfer each column using = or MOVE.
For big tables you could think about using a field-symbol for the loop. (LOOP AT table1 ASSIGNING <struc>).
Regards
Claudia