Hi all gurus!
Tricky questions here.. We'd like to implement a report which, given a table name, changes a specific field value for all the rows that satisfy a specific condition.
An example should be useful to clarify: suppose we're dealing with a custom table which has a field called ZFOO that can contain multiple values. Our report should then:
- get the table name as input parameter;
- loop over the fields (which are, since the table is dynamically known at runtime, unknown) to find ZFOO;
- loop over the table rows for the lines which have a specific value in ZFOO that meets the condition and change them accordingly.
Kinda tricky, anyway; as far as I've seen I can declare a parameter like:
PARAMETERS: p_table TYPE CHAR20.
and perform a SELECT dynamically, i.e. :
SELECT SINGLE * FROM (p_table) ... INTO ... wa or fs.
or SELECT into a table:
SELECT * FROM (p_table) ... INTO TABLE ... itab.
So, first question: how can I declare wa, fs or itab "dynamically" ? That's because the table name is unknown until runtime, also the wa, fs or itab should be "casted" dynamically.
For what concerns the second question... How can I loop over the FIELDS of a table whose type is unknown till runtime?
Thanks in advance,
M.