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

Connecting to Secondary database from ABAP program

Former Member
0 Likes
2,018

Guys,

I want to query a database table which is in secondary database (ORACLE). I am on SAP 4.6 and unable to use CONNECTION parameter of FROM clause. I want to use OPEN SQL. Any suggestions on this?

Thanks.

Guys,

I want to query a database table which is in secondary database (ORACLE). I am on SAP 4.6 and unable to use CONNECTION parameter of FROM clause. I want to use OPEN SQL. Any suggestions on this?

Thanks.

9 REPLIES 9
Read only

Former Member
0 Likes
1,478

Hi pramod,

1. for this u will also require help of basis team.

2. these are the steps.

a) make an entry in DBCON

b) make connection string

(on the physical application server,

so that it can connect to secondary database)

(this will be done by basis team,

in which, they will specify the

IP address of the secondary database server,

the DATABASE ID, and the port number)

c) then using open sql / native sql,

we can use the secondary database connection,

just like normal.

d) if we use open sql,

then there must be Y/Z table / view on

sap as well as secondary database,

and the field names , their type all should be identical.

regards,

amit m.

Read only

0 Likes
1,478

Thanks Amit.

The setting is in place and I am able to fetch data using Native SQL.

The problem is I want to fetch the data using Open SQL which is not happening. In case of Open SQL if I set the connection to secondary database and uses normal query, it returns me data which is available in primary database and not secondary. If I use CONNECTION parameter in FROM clause, it says wrong expression in from clause (I think this is bcoz I am on SAP 4.6). How to resolve this?

Regards,

PRAMOD

Read only

0 Likes
1,478

Hi again,

The connection parameter must be supplied immediately after the table name.

Also this will work with SELECT.... ENDSELECT only.

eg.




select * from t001
connection 'DBCON'
into itab
where bukrs = '1000'.

endselect.


regards,

amit m.

Read only

0 Likes
1,478

Hi Amit,

The query you posted is working on SAP 4.72 but not on SAP 4.6

Is there any way to use this query on 4.6C, like any patch or note?

Appreciated your response.

Thanks,

PRAMOD

Read only

0 Likes
1,478
Read only

0 Likes
1,478

Guys,

Still waiting for the answer, your response will be appreciated.

Read only

0 Likes
1,478

Hi,

Can I upgrade SAP 4.6 kernel to SAP 4.72 to enable this query to work? I don't want to upgrade whole system but want to avail certain commands which are not in 4.6. What would be the impact of upgrading kernel level to the system? How much time will it take?

Helpful answers will be highly appreciated.

Regards,

PRAMOD

Read only

former_member182371
Active Contributor
0 Likes
1,478

Hi,

there are several OSS Notes regarding this.

e.g.

https://service.sap.com/sap/support/notes/738371

This note proposes a test program:


REPORT  ZTESTDBCON.
data: DBN(128).
EXEC SQL.
   CONNECT TO 'TST'
ENDEXEC.
EXEC SQL.
   SET CONNECTION 'TST'
ENDEXEC.
EXEC SQL.
  SELECT db_name() INTO :DBN FROM SVERS
ENDEXEC.
WRITE: / 'current database name', DBN.

Have a look at them.

Best regards.

Edited by: Pablo Casamayor on Dec 18, 2009 11:29 AM

Read only

Former Member
0 Likes
1,478

Transaction DBCO.