‎2018 Dec 17 7:00 AM
Hi All,
I am making a report where the user chooses the names of tables he wants to select data from. I have to fetch data from these tables and upload the data as flat files to application server.
When writing the report, 2 things are unknown : name and number of tables. As the internal table also depends on the table, the structure will be unknown too.
Is there a way in which I can only write one select statement and it can be reused.
Something like:
Select * from [table name] into table [internal table name of same format].
where I can update the table name and internal table (which should be of the same format as the table) .
Thanks,
Samriddhi
‎2018 Dec 17 4:12 PM
you can write something like this
SELECT * FROM (p_table) INTO TABLE @DATA(lt_table) UP TO p_rows ROWS.
*lt_table will be dynamically created based on select output.
‎2018 Dec 17 8:44 AM
Take a look at program: DEMO_DYNAMIC_SQL, you will know how to build a dynamic SQL.
‎2018 Dec 17 4:12 PM
you can write something like this
SELECT * FROM (p_table) INTO TABLE @DATA(lt_table) UP TO p_rows ROWS.
*lt_table will be dynamically created based on select output.