10-06-2007 2:33 PM
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
10-06-2007 10:28 PM
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
10-06-2007 2:53 PM
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
10-06-2007 10:21 PM
Hi Raghu,
LOL.
SE11 may be able to copy the structure; it will never copy table contents.
Regards,
Clemens
10-06-2007 2:57 PM
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.
10-06-2007 10:28 PM
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
10-07-2007 5:21 AM
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