This website is not affiliated with, sponsored by, or approved by SAP AG.

Insert into table from another table...

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Insert into table from another table...

Postby 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
DrSidewalk
 
Posts: 180
Joined: Thu May 03, 2012 9:35 am

Re: Insert into table from another table...

Postby 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.
Grogan

Award cash if useful.
Grogan
 
Posts: 365
Joined: Thu Aug 04, 2005 7:16 pm
Location: Australia

Re: Insert into table from another table...

Postby banerjee_atanu » Sat Sep 06, 2014 6:48 pm

if number of records go into millions better use cursor -
http://wiki.scn.sap.com/wiki/display/ABAP/FETCH+and+OPEN+CURSOR+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>
banerjee_atanu
 
Posts: 5
Joined: Mon Dec 27, 2004 9:24 am


Return to ABAP

Who is online

Users browsing this forum: No registered users and 6 guests





loading...


This website is not affiliated with, sponsored by, or approved by SAP AG.