11-19-2008 5:31 PM
Hello,
In various SQL versions it is possible to define a variable that will hold the name of the table and then use that variable in the FROM clause instead the actual table name.
something like this:
var_table(4) type c.
var_table = 'tab1'
select * from &var_table&... etc
var_table = 'tab2'
select * from &var_table&... etc
It is possible something like this in ABAP SQL?
Thank you.
11-20-2008 3:12 AM
Hi,
yes, you can use the dynamic table for the SQL selection.
SELECT * FROM (tablename) INTO CORRESPONDING FIELDS OF TABLE <tab>.
Regards,
Chris Gu
11-19-2008 5:54 PM
yes, search using Dynamic Select, and you will find 1000s of threads
11-19-2008 7:17 PM
11-19-2008 8:11 PM
Check this :
https://www.sdn.sap.com/irj/scn/advancedsearch?query=dynamicSelect&cat=sdn_all
Regards
Neha
11-20-2008 3:12 AM
Hi,
yes, you can use the dynamic table for the SQL selection.
SELECT * FROM (tablename) INTO CORRESPONDING FIELDS OF TABLE <tab>.
Regards,
Chris Gu
11-20-2008 4:14 AM
Hi,
Check the foll code:
PARAMETERS: P_TABLE LIKE DD03L-TABNAME.
DATA: XTABLE TYPE REF TO DATA.
FIELD-SYMBOLS: <FS_TABLE> TYPE TABLE,
<WA_TABLE> TYPE ANY.
CREATE DATA XTABLE type TABLE OF (p_table).
assign xtable->* to <fs_table>.
SELECT * FROM (P_TABLE) INTO TABLE <fs_table> ORDER BY PRIMARY KEY.
loop at <fs_table> ASSIGNING <wa_table>.
ENDLOOP.
Thanks & Regards,
Navneeth K.