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: 

Fastest way to move from one itab to another?

0 Kudos

What is the fastest way to move one internal table to another internal table (assuming two tables of similar structure)?

a) append lines of table1 to table2.

b) loop at table1.

Move: table1-field1 to table2-field1,

table1-field2 to table2-field2.

Append table2.

Endloop.

c) table2[] = table1[].

d) loop at table1.

Move-corresponding table1 to table2.

Endloop.

e) move table1 to table2.

I think it is option a). Is it correct?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Best fast way is

itab2[] = itab1[].

5 REPLIES 5

Former Member
0 Kudos

Best fast way is

itab2[] = itab1[].

Former Member
0 Kudos

HI,

no the option is c.table2] = table1[.

as in b loop will be there which will take time,d will work if the table is huge

Thanks,

Rahul

Edited by: Rahul Kumar Sinha on Oct 14, 2008 8:17 AM

Former Member
0 Kudos

Hi,

Yes option a. is fastest : append lines of table1 to table2

In particular, the quickest way to fill a table line by line is to append lines to a standard table, since a standard table cannot have a unique key and therefore appends the lines without having to check the existing lines in the table.

APPEND LINES OF inttab1 TO inttab2.

This statement appends the whole of ITAB1 to ITAB2. ITAB1 can be any type of table, but its line type must be convertible into the line type of ITAB2.

This method of appending lines of one table to another is about 3 to 4 times faster than appending them line by line in a loop. After the APPEND statement, the system field SY-TABIX

contains the index of the last line appended. When you append several lines to a sorted table, you must respect the unique key (if defined), and not violate the sort order. Otherwise, a runtime

error will occur.

Reference : SDN ABAP Book.

thanx.

Former Member
0 Kudos

hi lohit,

MOVE ITAB1 TO ITAB2.

OR

ITAB1 = ITAB2.

These copy the contents of ITAB1 to ITAB2. Incase of internal tables with header line we have to use [] inorder to distinguish from work area. So, to copy contents of internal tables with header line the syntax becomes,

ITAB1[] = ITAB2[].

so ur option (C) and (E) are same.

and the fastest is both bcoz it copy entire contents of one table into another in one execution

Former Member
0 Kudos

This message was moderated.