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

Secondary database connections

Former Member
0 Likes
1,638

I am looking for information on Secondary database connections, especially with Oracle. Is there any other information than note 323151 (I am using the MiniSAP system for testing, therefor I do not have an official SAP customer status).

I found something about this on help.sap.com, but this is more like an overview. I am looking for some examples on what to configure and how to use it.

Any help would be appreciated.

Thanks

I am looking for information on Secondary database connections, especially with Oracle. Is there any other information than note 323151 (I am using the MiniSAP system for testing, therefor I do not have an official SAP customer status).

I found something about this on help.sap.com, but this is more like an overview. I am looking for some examples on what to configure and how to use it.

Any help would be appreciated.

Thanks

3 REPLIES 3
Read only

Former Member
0 Likes
887

Hi Klaus,

You can see SAP note 200164.

i had created one simple example program just for testing which i am pasting below. you can have a look at this also. I had made an entry in table DBCON as 'TEST' and saved other fields like user name and password for database.

REPORT zkrdbtst .

DATA dsn(10) VALUE 'DSN'.

DATA: BEGIN OF wa,

client(3), arg1(3), arg2(3),

END OF wa.

DATA f3(3).

**Connect to external database

EXEC sql.

connect to 'TEST' as 'CONN'

ENDEXEC.

**Set connection

EXEC sql.

set connection 'CONN'

ENDEXEC.

**Execute native SQLs.

*EXEC sql.

  • CREATE TABLE AVERI_CLNT (

  • CLIENT CHAR(3) NOT NULL PRIMARY KEY,

  • ARG1 CHAR(3) NOT NULL,

  • ARG2 CHAR(3) NOT NULL

*

  • )

*ENDEXEC.

*

EXEC SQL.

INSERT INTO AVERI_CLNT (CLIENT, ARG1, ARG2)

VALUES ('002', 9, 2)

ENDEXEC.

EXEC SQL.

SELECT * INTO :WA FROM AVERI_CLNT where client = '002'

ENDEXEC.

WRITE: / wa-client, wa-arg1.

**Disconnect

EXEC sql.

disconnect 'CONN'

ENDEXEC.

Read only

Former Member
0 Likes
887

Hi Klaus,

You need to prepare entries in the TNSNAME.ORA file (on the Oracle database server). The systemguys will know where to find it.

#

  1. Oracle File TNSNAMES.ORA (contains also the lines below)

#

texd.world = (DESCRIPTION = (ADDRESS = (COMMUNITY = tcp.world)

(PROTOCOL = TCP) (Host = <servername>) (Port = 1521))

(CONNECT_DATA = (SID = <SID>) (GLOBAL_NAME = texd.world)

(SERVER = DEDICATED)))

Replace <servername> with the actual servername of the oracle database.

Replace <SID> with the SAP system ID (Like DEV for development or PRD for production).

In SAP use transactiom SM30 to maintain table DBCON.

Give the connection a name (this is used in your code). Example = MYCONNECTION.

Set DBMS to ORA.

Set the username to a user with sufficient rights

Supply (2x) the password for this user

Set the Verb.info to textd.world

Do NOT check (leave unchecked) the Permanent checkbox.

Save your work.

In ABAP code you can connect to and use this connection like this:

  • Declaration

DATA: WA TYPE T000.

  • Init connection

EXEC sql.

connect to 'MYCONNECTION' as 'MYDB'

ENDEXEC.

  • Open connection

EXEC sql.

SET CONNECTION 'MYDB'

ENDEXEC.

  • Do your trick

EXEC sql PERFORMING your_form.

SELECT * INTO :WA FROM T000.

ENDEXEC.

  • Stop connection

EXEC sql.

disconnect 'MYDB'

ENDEXEC.

FORM your_form.

WRITE: / wa-mandt, wa-mtext.

ENDFORM.

Further information on using this (beside note 323151) can be found on notes 339092, 323151 and 178949.

See also http://www.akadia.com/services/ora_dblinks.html

Hope this helps you on your way.

Regards,

Rob.

Read only

Former Member
0 Likes
887

Timed out, close as cleanup