cancel
Showing results for 
Search instead for 
Did you mean: 

How to connect the external database through abap program.

Former Member
0 Kudos

Hi Frndz,

My requirement is to connect an external database....v hav a device and it has a database..... i hav used DBCON and created a record..which has

CON_NAME=DEV

DBMS = MSS

USER_NAME=**

PASSWORD=*/*

CON_ENV=MSSQL_SERVER=DEVSERVER MSSQL_DBNAME=MATSDB

when i execute this code

DATA: CONNECTION LIKE DBCON-CON_NAME VALUE 'BSS'.

DATA: CTRL_NO TYPE F,

CLOG_COD TYPE C,

GRP_COD(8) TYPE C,

DFECT_CODE(8) TYPE C.

EXEC SQL.

CONNECT TO :CONNECTION

ENDEXEC.

IF SY-SUBRC EQ 0.

EXEC SQL.

SET CONNECTION :CONNECTION

ENDEXEC.

EXEC SQL.

select control_no catalog_code group_code defect_code from defect_details into

:CTRL_NO, :CLOG_COD, :GRP_COD, :DFECT_CODE where control_no = 92269 and defect_code = '0076'.

ENDEXEC.

EXEC SQL.

SET CONNECTION DEFAULT

ENDEXEC.

EXEC SQL.

DISCONNECT :CONNECTION

ENDEXEC.

ENDIF.

after this statement

EXEC SQL.

CONNECT TO :CONNECTION

ENDEXEC.

it shows sy-subrc = 4.

how to solve this problem ?

whether the BASIS people has to do anthing with this?

plz give me the steps or link

Thanks

Arunprasad.P

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Arunprasad,

Please check if there are additional message in the develeoper trace file belonging to the process your program ran in (execute your program and then call in the same window sm50, the dialog process to your name running report SAPLTHFB is in most cases the one which ran the program before). If an error occurred on connect attempt, there should be the error messages listed.

Did you check if you can connect using the same user and password via Query Analyser or SQL Server Management Studio?

Best regards,

Guenther

P.S.

CON_NAME=DEV

DATA: CONNECTION LIKE DBCON-CON_NAME VALUE 'BSS'.

-- You used 'DEV', no?

Former Member
0 Kudos

Hi,

check Note 323151 - Several DB connections with Native SQL

please post your query in ABAP forum.

regards,

kaushal