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
2 Comments
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.

  • Hi Waldemar, good blog.

     

    according to note 1954060 – Inbound proxy transaction guard, commit work may not be used in abap proxy.

    In a synchronous inbound proxy, how do you use a bapi that requires explicit commit work? Is secondary databse connection a solution?

     

    many times we need to call more than one bapi for example (pseudo bapis that doesn't exists)

    BAPI_CREATE_CUSTOMER

    COMMIT WORK

    BAPI_CREATE_CONTRACT_ACCOUNT

    COMMIT WORK

    BAPI_CREATE_CONTRACT

    COMMIT WORK

    the bapi use "perform on commit" or "call function in update task" and explicit commit is required in between.
    you want the proxy to do all or nothing.

    You want to return a message to the consumer of the proxy wheter it worked or not, or if it worked partially. 

    /O