Application Development and Automation 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: 
Read only

EXEC SQL: Internal table and loop needed to push records from SAP?

Former Member
0 Likes
1,013

Hello,

I have a requirement to perform a table extract from SAP to External Database using DBCO config and Native SQL. The source system is Oracle ECC 6.0 and the target is an external MS SQL Server database (non-SAP).

Technical questions:

1) Do you have to use an internal table and loop to insert each record into the external database? Is it possible to pass an entire table or group of records in one call?

2) See any places for optimization here? I will look into using the PACKAGE SIZE to control the size of the internal tables, but it appears the bottleneck is the loop.

*Get source data and insert into ITAB

SELECT  *
  INTO TABLE lt_jest
  FROM jest.

*?????????????????????????????????????????????????????????????*
* #### IS IT POSSIBLE TO NOT LOOP OVER EACH RECORD HERE? #### *
*?????????????????????????????????????????????????????????????*

*Loop at ITAB and insert into SQL Server one record at a time

  LOOP AT lt_jest ASSIGNING <FS>.
    EXEC SQL.
      INSERT INTO [dbo].[JEST]
       VALUES (:<FS>-MANDT,:<FS>-OBJNR,:<FS>-STAT,:<FS>-INACT,:<FS>-CHGNR);
        commit;
    ENDEXEC.
  ENDLOOP.

2 REPLIES 2
Read only

Former Member
0 Likes
537

Not sure why we would want to use ABAP to do this. If it were me, I'd ask Basis or DBA to extract and push to new table using SQL on the db server, not through an ABAP program.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
537

Hello,

SAP has provided standard API for connecting with external database ADBC. Refer: [ADBC - ABAP Database Connectivity |http://help.sap.com/abapdocu_70/en/ABENADBC.htm]

Instead of writing the Native SQL you can make use of the methods of the ADBC classes. Refer to the demo program ADBC_DEMO for details.