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: 

copy a table with records to a new table

Former Member
0 Kudos

Is it possible to copy the entire table with its contents to a new table. If so, pls explain. Thank you.

1 ACCEPTED SOLUTION

former_member156446
Active Contributor
0 Kudos

hi SRK

assumptions: both the table structures are the same.

the primary keys are the same.


data: begin of itabA.
         include structure A.
data: end of itabA.

data: begin of itabB.
         include structure B. <<<<< if needed.
data: end of itabB.

      select * from A into table itab.

      delete table B.

       modify table B by itab.

The structure of Itab will the same structure of the Ztable we are updating.

in the above case it will be of type B,

Edited by: Jackandjay on Jan 27, 2008 6:09 PM

4 REPLIES 4

Former Member
0 Kudos

Hi,

Its possible to copy one table to another with records but there are few limitations.

The table structure of both the internal tables should be exactly same i.e the field names and the field length.

Then define the new table and just use the assignment statement to copy.

For E.g. - A[] = B[]

Here table B is copied on to table A[]. The contents of internal table A are completely overwritten by the contents of internal table B.

former_member156446
Active Contributor
0 Kudos

hi SRK

assumptions: both the table structures are the same.

the primary keys are the same.


data: begin of itabA.
         include structure A.
data: end of itabA.

data: begin of itabB.
         include structure B. <<<<< if needed.
data: end of itabB.

      select * from A into table itab.

      delete table B.

       modify table B by itab.

The structure of Itab will the same structure of the Ztable we are updating.

in the above case it will be of type B,

Edited by: Jackandjay on Jan 27, 2008 6:09 PM

0 Kudos

Hi Jackandjay

what is the structure of itab.. i mean it is declared of which type?

Clemenss
Active Contributor
0 Kudos

Hi srk,

this is a typical "If I don't know how top press F1 I have to try" question.

[Conversion Rules for Internal Tables (SAP Library - ABAP Programming (BC-ABA)):|http://help.sap.com/saphelp_erp2005vp/helpdata/en/fc/eb34d0358411d1829f0000e829fbfe/content.htm]

Regards,

Clemens