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: 

Copying data from one internal table to another internal table.

former_member787646
Contributor
0 Kudos

Hi friends,

I have the following requirement. Please provide me a solution.

eg: 1st Internal Table Structure (having 100 records)

A type char(10),

B type char(10),

C type char(10)

2nd Internal Table Structure ( having no records)

A type char(10),

B type char(10),

C type char(10),

D type char(10)

I want to copy data from Ist internal table to 2nd internal table at one go (in a single step) considering all the performance aspects. I don't want to use MOVE-CORRESPONDING in this case.

Thanks in Advance.

1 ACCEPTED SOLUTION

Former Member

Hi,

In such cases best to use APPEND LINES syntax.

You can also append internal tables to index tables using the following statement:

APPEND LINES OF itab1 TO itab2.

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 : help.sap.com

thanx.

8 REPLIES 8

Former Member
0 Kudos

hi

i dont think there is a way of transfering data in one step.

you to use loop and move-corr

regards

vivek

Former Member
0 Kudos

2nd_itab[ ] = 1st_itab[ ].

Edited by: -=Bo0h=- on Sep 15, 2008 6:21 AM

kesavadas_thekkillath
Active Contributor

append lines of itab1 to itab2.

Former Member

Hi,

In such cases best to use APPEND LINES syntax.

You can also append internal tables to index tables using the following statement:

APPEND LINES OF itab1 TO itab2.

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 : help.sap.com

thanx.

Former Member

The fastest way is

table2[] = table1[]

because you copy the first three fields in the same order in the second table and cut the third field. In othe way you need to make a loop and move-corresponding and append

0 Kudos

table2 [ ] = table1 [ ]

When i talk about third field is fouth field

sorry

Former Member
0 Kudos

hi

in ur case i think it is not possible because

append lines of itab1 to itab2 can be used only they are of same structure

or

itab1 = itab2

this is also for the same case

so only thing is move corresponding

itab 1 to itab 2

with regards

s.janagar

0 Kudos

Have u ever tried ???

Both are possible.....