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

Data extract from MS Sql Server db to SAP

former_member588855
Active Contributor
0 Likes
2,627

Hi Experts ,

Can some one guide me extracting Data from SQL server to SAP System .

We have a seperate Non SAP system with MS SQL Server database .

Now requirement is to get those data s into Our SAP system.

We will create a Ztable and a RFC function module for that .

We will not deal with the Non-SAP application program rather we want to get data from directly databse (SQL).

User will run a program from SAP end and it will fetch data from that database(SQL) .

What is the methodology for that??

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,654

Hello,

Instead of using Native SQL, you should check the [ADBC classes|http://help.sap.com/abapdocu_702/en/abenadbc.htm] for retrieving data from external databases.

BR,

Suhas

5 REPLIES 5
Read only

Former Member
0 Likes
1,654

Hi,

SAP provided one option to connect directly the other database tables and fetch data, that is DB connection.

To establish DB connection, need to do below activities:

1. Register TNS entry of the source DB(remote DB) in SAP DB level

2. Configure the connection in DBCO transaction.

Once DB connection is activated , remote data can be fetched from SAP using native SQL.

For more details refer below thread on native sql

http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb3b8b358411d1829f0000e829fbfe/content.htm

Regards,

Chandra

Read only

Former Member
0 Likes
1,654

Hi,

well, just let me give you some more detailed answer.

Start transaction dbco to get into the DB-connection GUI. There you can enter the IP etc. of your MSSQL server. Take a look on the exisitng one as a template. Name the connection by your own.

In your program you need to open the connection by using this code:

DATA: dbs TYPE dbcon-con_name.

dbs = 'servername'.

  • open connection to MSSQL DB

EXEC SQL.

CONNECT TO :dbs

ENDEXEC.

Use any SQL command by putting it between EXEC SQL. and ENDEXEC.

example on select command:

EXEC SQL.

select single from server_table where bla = 'a' into ls_blub

ENDEXEC.

don´t forget to disconnect:

EXEC SQL.

DISCONNECT :dbs

ENDEXEC.

and for error handling:

if sy-subrc NE 0.

SKIP.

WRITE: 'error reading ls_blub'.

ENDIF.

mandatory to have changes effect on:

CALL FUNCTION 'DB_COMMIT'.

I hope that this application-oriented information will help you to have it done.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,655

Hello,

Instead of using Native SQL, you should check the [ADBC classes|http://help.sap.com/abapdocu_702/en/abenadbc.htm] for retrieving data from external databases.

BR,

Suhas

Read only

0 Likes
1,654

Hi ,

Thank you all for your suggestions . I understood what needs to be done from ABAP side .

Now problem is coming from BASIS side . Coz we have UNIX platform in SAP whereas in SQL we have Windows platform.

Can anybody have any idea how to build up connection with that 2 different platform db. I mean before going to t-code

DBCO any other step should we have to follow??

.

Regards

Read only

Former Member
0 Likes
1,654

Hi,

Please refer my previous answer..

You need to register sql db tns entry in SAP.. Please check with your DB admin

Thanks and Regards,

Chandra