‎2008 Feb 15 2:08 PM
QUESTION : How can I copy a existing table (including some records) into another table . The copy function on Application tool bar of ABAP dictionary copies the table structure into a new table having a user given name OK .No problems till here. Now how can i copy the contents of 1st table to 2nd table ?????
‎2008 Feb 15 2:13 PM
1. Created a small program for that. Read the data from 1st table into a internal table and then update the second database table my the internal table.
2. Second option is Download the first Internal table and then through the program upload the downloaded data into another table.
To download a database table contents as follows:
1. Reach to the table contents acreen in se11.
2. Menu bar -> system -> list -> save -> Local file.
‎2008 Feb 15 2:13 PM
1. Created a small program for that. Read the data from 1st table into a internal table and then update the second database table my the internal table.
2. Second option is Download the first Internal table and then through the program upload the downloaded data into another table.
To download a database table contents as follows:
1. Reach to the table contents acreen in se11.
2. Menu bar -> system -> list -> save -> Local file.
‎2014 Nov 19 10:06 AM
Hi,
It looks a weird way to pull data to somewhere (to the application server or client-side file) and then push it back to the database instead of just simply copying data at the database level:
data(l_conn) = cl_sql_connection=>get_connection( ).
cl_demo_output=>display(
l_conn->create_statement( )->execute_update(
'insert into your_dest_tabname select * from your_src_tabname' ) && ' rows processed.'
).
l_conn->commit( ).
l_conn->close( ).
It should work for most of databases and platform-dependency should not be an issue (moreover, it's a single task).
Using of internal table is very interesting in case of millions of records and lots of GB table size. Use import/export database utilities instead or insert ... select inside the database.
Regards,
Andrew.
‎2008 Feb 15 2:15 PM
Hi,
download the Entire Contents to some EXCEL Sheet.
Then create the program where u copy that contents to some internal table and insert that data into ur database table.
*If useful Reward with Points*
‎2008 Feb 15 2:15 PM
Hi,
To copy the contents of the database table to copied, you have to write a se 38 program. First fetch all the data into an internal table. The internal table is declared like database table. Then modify your copied database table from internal table.
regards,
kamala.
‎2008 Feb 15 3:06 PM
Im asking that I have got the data from database table into internal table. NOW how can i move data from my internal table to the database table. Say itab is the int table and dtab is the data base table. Plz write the exact syntax.
‎2008 Feb 15 3:09 PM
Hi,
If you want to pass the data from internal table to Database table..use INSERT statement
First Declare the internal table structure as Database Table.
and fill the internal table with data.
and use INSERT statement.
Check this program...
TABLES:MARA.
DATA:ITAB LIKE MARA OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
ITAB-MATNR = '123ABCDA'. .
ITAB-MBRSH = 'C'.
ITAB-MTART = 'FERT' .
ITAB-MEINS = 'KG' .
APPEND ITAB.
ITAB-MATNR = '123ABCDB'. .
ITAB-MBRSH = 'C'.
ITAB-MTART = 'FERT' .
ITAB-MEINS = 'KG' .
APPEND ITAB.
LOOP AT ITAB.
INSERT MARA FROM ITAB.
MODIFY MARA .
ENDLOOP.
‎2008 Feb 15 3:39 PM
OK problem solved but the portion
LOOP AT ITAB.
INSERT MARA FROM ITAB.
MODIFY MARA .
ENDLOOP.
should be as
LOOP AT ITAB.
INSERT MARA FROM ITAB.
ENDLOOP.
secondly plz tell me the other way i.e uploading / downloading..
ive downloaded my table records in .txt / .xls format... NOW Where should i click 2 upload it ?
‎2008 Feb 15 3:11 PM
I wouldn't bother. Your DBAs can do this much more quickly using their database utilities.
Rob
‎2008 Feb 16 5:17 AM
WAS a ANSWER WHICH FULFIL THE REQUIREMENT BUT IS NOT THE CORRECT WAY.
‎2009 May 24 9:39 PM
‎2022 Jul 13 9:34 AM
In a 7.50 Release you can write following if the tables are identical:
INSERT znewtab FROM ( SELECT * FROM zoldtab ).