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

Connection with Oracle

Former Member
0 Likes
897

Dear,

I want to access and read from Oracle 9i tables from SAP.

How can i do this.

Do i have to do anything from basis side or write a connection string in ABAP.

Regards,

Priya

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
869

Hi Priya,

First of all check whether DB connection is done from transaction DBCO. If no connection is made then ask your basis team to do this.

Then is your program were you want to read the table from oracle 9i write a code like this:

The table can be read with the help of declaring a cursor type data.

EXEC SQL.
  CONNECT TO 'MYCONNECTION' " Name of DB connection
ENDEXEC.
EXEC SQL.
  open c for
    SELECT * from PVACCOUNTBALANCE2
ENDEXEC.
DO.
  EXEC SQL.
    FETCH NEXT c INTO :ithead " internal table for data
  ENDEXEC.
  append ithead.
  IF sy-subrc ne 0.
    EXIT.
  ENDIF.
ENDDO.
EXEC SQL.
  CLOSE c
ENDEXEC.
EXEC SQL.
  DISCONNECT :'MYCONNECTION'
ENDEXEC.

I hope this answers your query.

Regards,

Brajvir

Dear,

I want to access and read from Oracle 9i tables from SAP.

How can i do this.

Do i have to do anything from basis side or write a connection string in ABAP.

Regards,

Priya

6 REPLIES 6
Read only

Former Member
0 Likes
869

Check SAP note 323151

Read only

Former Member
0 Likes
870

Hi Priya,

First of all check whether DB connection is done from transaction DBCO. If no connection is made then ask your basis team to do this.

Then is your program were you want to read the table from oracle 9i write a code like this:

The table can be read with the help of declaring a cursor type data.

EXEC SQL.
  CONNECT TO 'MYCONNECTION' " Name of DB connection
ENDEXEC.
EXEC SQL.
  open c for
    SELECT * from PVACCOUNTBALANCE2
ENDEXEC.
DO.
  EXEC SQL.
    FETCH NEXT c INTO :ithead " internal table for data
  ENDEXEC.
  append ithead.
  IF sy-subrc ne 0.
    EXIT.
  ENDIF.
ENDDO.
EXEC SQL.
  CLOSE c
ENDEXEC.
EXEC SQL.
  DISCONNECT :'MYCONNECTION'
ENDEXEC.

I hope this answers your query.

Regards,

Brajvir

Read only

0 Likes
869

Hi Brajvir,

What is the declaration of the Internal Table ?

Read only

0 Likes
869

Dear,

It is same as normal internal table we declare for abap programming.

Regards,

Priya

Read only

0 Likes
869

hi Priya,

i mean, what is the structure of the iternal table. Do we need to declare the fileds in the internal table having the same structure of remote server table stucture ?

Read only

0 Likes
869

Yes u will have to declare the same structure that of remote server table.

Regards,