2015 Jun 09 9:40 AM
Hi..All,
I have requirement to read data form Oracle data base(external system) To SAP .
The connections are fine in DBCO and Able to connect to the Oracle server (ITR2) .
And i have done coding as below:
EXEC SQL.
CONNECT TO 'ITR2'
ENDEXEC.
EXEC SQL.
open c for
SELECT * from GDPA_CIS
ENDEXEC.
DO.
EXEC SQL.
FETCH NEXT c INTO :it_sap
ENDEXEC.
append it_sap.
IF sy-subrc ne 0.
EXIT.
ENDIF.
ENDDO.
EXEC SQL.
CLOSE c
ENDEXEC.
EXEC SQL.
DISCONNECT :'ITR2'
ENDEXEC.
I am getting dump AS attached.
How can i trouble shoot this..
2015 Jun 09 10:37 AM
Hi Mahesh ,
The best way to troubleshoot is to use the tcode - DBACOCKPIT .
from the dump it seems the Table name you have specified in Native SQL quert SELECT * FROM <TABNAME> does not exist in the underlying DB connection "DEFAULT"
You can try to directly execute the query in "SQL Command Editor" ( In Diagnostics node) there , using the native DB query Language and see if the object exists
Hope it helps .
Best Regards,
Rini
P.S : Pls mark the answer as correct/helpful if so.
2015 Jun 09 5:51 PM
Hi..Rini,
The Table is there in External Oracle data base .
And am able to connect to the external DB with below syntax.
EXEC SQL.
CONNECT TO 'ITR2'
ENDEXEC.
But when reading table with below syntax- its going to dump.
EXEC SQL.
open c for
SELECT * from GDPA_CIS
ENDEXEC.
Still any settings missing...
2015 Jun 09 6:12 PM
Hi Mahesh ,
As you are using Native SQL , so probably you will also have to specify the system id along with table name . So your query should be like :
select * from <sap system id>.<table name>
You can also test the above sql command in the SQL Command Editor(under Diagnostics) in tcode - DBACOCKPIT mentioned in my previous reply.
One more suggestion , why do u want to use native as You can also use cursors in Open SQL.
Best Regards,
Rini
P.S : Please mark the answer as helpful or correct if so.
2015 Jun 09 1:35 PM
Hi,
Try to run the query directly on the console of the external database.
Best Regards from Brazil.
2015 Jun 09 5:54 PM
Hi..Ferreira,
In Oracle server we have tested the table - GDPA_CIS.
Its there with 20 records.
But when accessing it through ABAP,Its going to dump.
Regards,
Mahesh
2015 Jun 09 6:15 PM
Hi
Perhaps you need to indicate a particular schema where the table is
Max
2015 Jun 10 2:35 PM
Hi Mahesh,
After connect to statement , use set connection as below;
EXEC SQL.
CONNECT TO 'ITR2'
ENDEXEC.
EXEC SQL.
SET CONNECTION 'ITR2'
ENDEXEC.
IF sy-subrc <> 0.
RAISE EXCEPTION TYPE cx_sy_native_sql_error.
ENDIF.
EXEC SQL.
open c for
SELECT * from GDPA_CIS
ENDEXEC.
Hope it helps,
BR.