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: 

How to copy content?

Former Member
0 Kudos

Hi ,

I just wanna copy the content of one transparent table to another transparent table.

I have created two tables with same fields. In one table content is their and in other its not.

Please tell me all the methods to do that?

And which one is best in terms of good programiong?

Reward points sure>>>>

Thanks, Ajay

1 ACCEPTED SOLUTION

Clemenss
Active Contributor
0 Kudos

Hi ajay,


parameters:
  p_old type tabname,
  p_new type tabname.
field-symbols:
  <tab> type standard table.
data:
  lr_tab type ref to data.
create data lr_tab type table of (p_old).
assign lr_tab->* to <tab>.
select * from (p_old) into table <tab>.
insert (p_new) from table <tab>.
write: sy-dbcnt. 'entries copied from', p_old, 'to'. p_new.

This is without any checks if the tables are compatible - this is what you may add.

Regards,

Clemens

5 REPLIES 5

Former Member
0 Kudos

Hi

You can just copy structure of one table into another using COPY option in SE11.

Message was edited by:

Raghu Reddy

Message was edited by:

Raghu Reddy

0 Kudos

Hi Raghu,

LOL.

SE11 may be able to copy the structure; it will never copy table contents.

Regards,

Clemens

Former Member
0 Kudos

If you want to do it programmatically you can do like this.

data:itab type standard table of dbtab with header line.

select * from dbtab into table itab.

loop at itab.

insert into dbtab1 values itab.

if sy-subrc <> 0.

You can collect error records here.

endif.

endloop.

Clemenss
Active Contributor
0 Kudos

Hi ajay,


parameters:
  p_old type tabname,
  p_new type tabname.
field-symbols:
  <tab> type standard table.
data:
  lr_tab type ref to data.
create data lr_tab type table of (p_old).
assign lr_tab->* to <tab>.
select * from (p_old) into table <tab>.
insert (p_new) from table <tab>.
write: sy-dbcnt. 'entries copied from', p_old, 'to'. p_new.

This is without any checks if the tables are compatible - this is what you may add.

Regards,

Clemens

Former Member
0 Kudos

Hi Clemens and Ajay,

Sorry my mistake...............Anyways I suggested Programmatical method also.

Message was edited by:

Raghu Reddy

Message was edited by:

Raghu Reddy