Application Development 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: 

How to connect to DB2 from ABAP program

Former Member
0 Kudos

Hi,

In my ABAP program I need to retrieve 3 fields from one table of DB2 database. I have tried creating an RFC connection in SM59 and then using native SQL in abap code but could not succeed.

I have also maintained an entry in DBCON table but am unable to connect through program.

Pls suggest.

Thanx in advance.

3 REPLIES 3

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I have tried this in the past, I wanted to access data from an external SQL database on another machine. I couldn't get it to work, and someone told me that I need to have a "Windows" application server in order for it to work. Since we run on AS400, i never got it working.

Regards,

Rich Heilman

Former Member
0 Kudos

Hi,

Thanx for your prompt response. Our R3 is running on Oracle. I think 'connect' syntax should work but I am not sure where the error is.

Former Member
0 Kudos

Preeti-

DBCON may not work for you because your target is DB2. You SAP system should have the suitable driver files for connecting to DB2 and I don't think currently this is supported.

However, there are other ways of doing it. One ofcourse is to use a middleware tool, which I guess you don't have in your landscape.

If investing on a middleware tool is out of scope, here are other options

1) If you are a microsoft shop, use .NET connector (freely downlaodable from SAP service market place). You can develop a .NET component which will use .NET connector for connecting to SAP and OBDC to connect to your AS400 system. The OBDC drivers can be obtained from IBM.

2) If you are a java shop, you can develop a java code which can run on your AS400 system or a separte server (windows,unix..).

This java code will use JRFC/JCO (again downloadable for free from SAP service market place) to connect to SAP while it will use Client access ODBC drivers or JT400 drivers (google JT400) to connect to your DB2 database.

Though developing this is not a great deal, could be bit challenging if done for the first time. Let me know which way you wanna go and I can guide with more information/code samples.

KK