- i Actually copied program code from the link you sent. but it still not working. Is there any other way we can test if the database connection is working with the parameters provided in DBCO? I am in the same network as of the oracle database so i do not think its the firewall problem.
I get sy-subrc = 4 after line "CONNECT TO :dbs" belowHere is the code ... PARAMETERS dbs TYPE dbcon-con_name.
DATA carrid_wa TYPE scarr-carrid.
DATA dbtype TYPE dbcon_dbms.
SELECT SINGLE dbms
FROM dbcon
INTO dbtype
WHERE con_name = dbs.
IF dbtype = 'ORA'.
TRY.
EXECSQL.
CONNECT TO :dbs
ENDEXEC.
IF sy-subrc <> 0.
RAISE EXCEPTION TYPE cx_sy_native_sql_error.
ENDIF.
EXECSQL.
OPEN dbcur FOR
SELECT carrid
FROM scarr
ENDEXEC. DO.
EXECSQL.
FETCHNEXT dbcur INTO :carrid_wa
ENDEXEC.
IF sy-subrc <> 0.
EXIT.
ELSE.
WRITE / carrid_wa.
ENDIF.
ENDDO.
EXECSQL.
CLOSE dbcur
ENDEXEC.
EXECSQL.
DISCONNECT :dbs
ENDEXEC.
CATCH cx_sy_native_sql_error.
MESSAGE`Error in Native SQL.`TYPE'I'.
ENDTRY.
ENDIF.
↧
Re: Connecting to external database using ABAP
↧