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

Native SQL in ABAP

Former Member
0 Likes
597

Hi ,

I have to bring in data from a view created in FIDO into my ABAP program . The database is oracle. I am trying to use basic forms of native sql embedded in my code to retrieve the data , but I get a short dump stating that the table does not exist.

I am using the following code :

DATA: BEGIN OF wa,

field_id(32) type c,

field_common_name(100) TYPE c,"spfli-cityfrom,

END OF wa.

DATA c1(32) TYPE C VALUE 'LH'.

EXEC SQL PERFORMING loop_output.

SELECT field_id, field_common_name

INTO :wa

FROM v_field

WHERE field_id = :c1

ENDEXEC.

FORM loop_output.

WRITE: / wa-field_id, wa-field_common_name.

ENDFORM.

1 ACCEPTED SOLUTION
Read only

former_member194669
Active Contributor
0 Likes
559

Because "V_FIELD" is not a valid table


EXEC SQL PERFORMING loop_output.
SELECT field_id, field_common_name
INTO :wa
FROM v_field  " <<<< -----
WHERE field_id = :c1
ENDEXEC.

a®

3 REPLIES 3
Read only

former_member194669
Active Contributor
0 Likes
560

Because "V_FIELD" is not a valid table


EXEC SQL PERFORMING loop_output.
SELECT field_id, field_common_name
INTO :wa
FROM v_field  " <<<< -----
WHERE field_id = :c1
ENDEXEC.

a®

Read only

0 Likes
559

I checked and the table exists , is it because I have to connect to the external database first. I do not know how to connect to an external database. Is that some code segment I have to add to my abap program .

thanks

Read only

0 Likes
559

Hi.

First of all you have to define a database connection to the external database you want to use. Database connections are stored in table DBCON. Use transaction DBCO or DBACOCKPIT to maintain them. The latter offers much more help and a test if all parameters are set correctly. Search SDN for details.

Then you have to open the connection you want to use before you do your EXEC SQL.

EXEC SQL.

CONNECT TO <con_name> AS <alias_name>

ENDEXEC.

Please search the forums for further details. Or browse the online docu / F1 help. You will find a lot of further information.

Best regards,

Jan Stallkamp