Insert into table from another table...

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Post Reply
Posts: 180
Joined: Thu May 03, 2012 9:35 am

Insert into table from another table...

Post by DrSidewalk » Wed Sep 03, 2014 6:40 am

I know that I can extract records from one transparent table into an internal table, and then insert the records from the internal table into another transparent table, but, that takes time, and uses a lot of memory if the itab is huge.

With Native SQL (Oracle) it's possible to use an SQL statement like INSERT a b c FROM table WHERE ....
This is much much faster than returning all the resulting records from the first open SQL statement into an internal table and the inserting the results into another table, again using Open SQL.

However, we are not allowed to use Native SQL; the code will never get passed peer check, and I therefore wondered it it was possible via Open SQL. Perhaps some hidden but seldom used Open SQL functionality. One can hope.

Dr Sidewalk

Posts: 365
Joined: Thu Aug 04, 2005 7:16 pm
Location: Australia

Re: Insert into table from another table...

Post by Grogan » Wed Sep 03, 2014 3:55 pm

Not to my knowledge.

However it is possible to use OPEN CURSOR... DO. FETCH NEXT CURSOR... ENDDO. to read and then insert the records in blocks. This won't help with the processing time, but will limit the memory required.

Award cash if useful.

Posts: 5
Joined: Mon Dec 27, 2004 9:24 am

Re: Insert into table from another table...

Post by banerjee_atanu » Sat Sep 06, 2014 6:48 pm

if number of records go into millions better use cursor - ... R+Analysis, meticulous use of "package" option would save you time and memory.
otherwise for moderate number of records go for
select a b c ... from ... into corresponding fields of <itab> .... where ....
insert <dbtab> from table <itab>

Post Reply