‎2009 Feb 27 9:04 AM
Dear all
i like to have a SQL statement with a dynamic tablename. Is this possible? If yes, how?
should be something like "select * from <mytablename>"
Thank you
Herbert
‎2009 Feb 27 9:11 AM
Yes this is possible. use the below reference code for this.
data: g_tablename type w_tabname,
gv_dref TYPE REF TO data.
FIELD-SYMBOLS: <g_itab> TYPE STANDARD TABLE.
gv_tabname = p_tablename (take table name form selection screen or as per ur requirement)
CREATE DATA gv_dref TYPE TABLE OF (g_tabname).
ASSIGN gv_dref->* TO <g_itab>.
now use the below select query to fetch the data
SELECT * FROM (gv_tabname) INTO TABLE <g_itab>.
Hope this will help
‎2009 Feb 27 9:07 AM
Hi,
It's possible.
Ex;
w_tabname = 'MARA'.
select * from (w_tabname) into table ...
‎2009 Feb 27 9:07 AM
Hi,
U can try like this,
Select
select * from zcostfreq
where (where_tab).
endselect.
regards,
Neelima.
‎2009 Feb 27 9:08 AM
You can have dynamic statement .
select * from (sname)
into table
‎2009 Feb 27 9:11 AM
Yes this is possible. use the below reference code for this.
data: g_tablename type w_tabname,
gv_dref TYPE REF TO data.
FIELD-SYMBOLS: <g_itab> TYPE STANDARD TABLE.
gv_tabname = p_tablename (take table name form selection screen or as per ur requirement)
CREATE DATA gv_dref TYPE TABLE OF (g_tabname).
ASSIGN gv_dref->* TO <g_itab>.
now use the below select query to fetch the data
SELECT * FROM (gv_tabname) INTO TABLE <g_itab>.
Hope this will help