2012 Jun 15 8:41 AM
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
2012 Jun 15 8:52 AM
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
2012 Jun 15 8:55 AM
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