Skip to Content

Secondary database connections in ABAP

The SAP NetWeaver AS ABAP can acces in addition to his primary database other databases. This is known as so-called secondary databases or secondary database connections. The technical steps in this section describe the setup and use of secondary database connection. Secondary connections play an importand role in the context of SAP HANA. Complex database queries with long runtimes can be outsorced into SAP HANA.

  • The basic requirement for setting up a socondary database connection is the installation of the appropriate Database Shared Library (DBSL) with the database driver, so in this case of SAP HANA DBSL with the SAP HANA client.
  • After that, new connections can be created in the Database Administrator Cockpit with the transaction DBACOCKPIT (or with transaction ST04).

Blog1.PNG

  • After creating the secondary connection in the Database Cockpit data can be accessed and tested.
  • Secondary database connection can be accessed with Open SQL and native SQL.
    • In Open SQL it is possible with the addition CONNECTION in a SQL statement
    • In native SQL or in ADBC (ABAP Database Connectivity) the secondary database connection can be called during generating the Connection

Sample: https://wiki.scn.sap.com/wiki/display/Snippets/ABAP+-+Secondary+database+connection

/
Blog1.PNG
1 Comment
You must be Logged on to comment or reply to a post.
  • Hi Waldemar,

    I have a remote connection in DBCON (called “CONN1”).

    I am trying to INSERT * (all records) from SAP (DEFAULT connection) to a remote table (via DBCON connection “CONN1”) with the same structure.

    I have tried all kinds of syntax including:

    EXEC SQL.

    INSERT INTO CONN1.SCHEMA.TABLE_NAME

    (SELECT * FROM TABLE_NAME)

    ENDEXEC.

    and I always get a short dump (SQL error).

    My only success has been to insert all records from TABLE_NAME (in the DEFAULT SAP connection) into an internal table (ITAB) and then Connect to CONN1 and then LOOP at the ITAB and INSERT records into the Remote table one by one. But this is VERY SLOW. We need to be able to do a INSERT with Sub-Select as I described above in two different schemas (CONN1 and DEFAULT).

    Any advice you can provide will be greatly appreciated!

    Thank you very much, Chris T.