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

variable table name in native SQL

Former Member
0 Likes
801

Hi

We have an ABAP program which writes data to a database, then updates a header table to say it is finished.  Our problem is that the program is run from various different places, so the header table is different each time, so we tried to pass the table name as an input. e.g.

REPORT z_myData.

SELECTION-SCREEN:...

PARAMETERS: ip_table.

PARAMETERS: ip_ID.

...connect to oracle database...

...write data...

EXEC SQL.

     UPDATE :ip_table

     SET FINISHED = 1

     WHERE DOWNLOAD_ID = :ip_ID

ENDEXEC.

...commit...

...disconnect...

This works great if we change it to "UPDATE z_table1...", but returns an oracle error "ORA-00903: invalid table name" with the variable.

Can the table name be passed in this way?

Thanks

Nick

2 REPLIES 2
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
520

You cannot use dynamic variables with native sql. Use ADBC classes and do it.

Refer the documentation here: http://help.sap.com/abapdocu_702/en/abenadbc.htm

Check the demo program adbc_demo

Read only

ThomasZloch
Active Contributor
0 Likes
520

Did you look into using the ADBC functionality?

http://help.sap.com/abapdocu_702/en/abenadbc.htm

You would be able to dynamically construct the query, as in this example:

http://help.sap.com/abapdocu_702/en/abenadbc_query_abexa.htm

Thomas

P.S. somebody was quicker