Skip to Content
0
Former Member
Nov 29, 2006 at 08:04 AM

How to get data from an external DB (Oracle) into internal table

345 Views

PARAMETERS dbs TYPE dbcon-con_name.

Dear Experts,

Currently, i have a requirement from customer to read data from a table in another database server (Oracle). I had set the necessary settings in tcode DBCO and i had developed a simple program as below but it seems like i couldn't connect to the database.

May i know the steps if we would want to read data from table in another database or am i missing out something??

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.

EXEC SQL.

CONNECT TO :dbs

ENDEXEC.

IF sy-subrc <> 0.

RAISE EXCEPTION TYPE cx_sy_native_sql_error.

ENDIF.

EXEC SQL.

DISCONNECT :dbs

ENDEXEC.

CATCH cx_sy_native_sql_error.

MESSAGE `Error in Native SQL.` TYPE 'I'.

ENDTRY.

ENDIF.

Thank you.