‎2010 Mar 25 3:15 AM
Dear SAP gurus
I have a question on using parameters passed in a custom BAPI in SQL statements.
I am sending 2 parameters TABLENAME, COLUMNNAME into a custom bapi.
In the BAPI I need to give an sql command some thing like
select * from TABLENAME where COLUMNNAME = '100'.
Where TABLENAME and COLUMNAME may vary depend on what parameters are sent while calling this BAPI.
Even defining an internal table that has the structure of TABLENAME is not working.
I used the following statement 'data: ls_TABLENAME type TABLENAME', which generates error message saying TABLENAME is unknons.
Any feedback will be highly appreciated.
Thanks
Ram
‎2010 Mar 25 1:22 PM
As far as I know you can not give parameter to a select query like that. You should describe the tablename and the columnname as string type. Then assign the values to them you want to use in query.
data: str_table type string.
data: str_column type string.
select * from (str_table) into <g_t_table> where (str_column) = '100'.
If the table name is not determined until runtime, you must specify an output area with INTO .