I'm working on a generic report where I need to read values dynamically from different fields in an internal table based on user selection.
How can I retrieve a field's value dynamically when the field name is provided as a string?
I'm working on a generic report where I need to read values dynamically from different fields in an internal table based on user selection.
How can I retrieve a field's value dynamically when the field name is provided as a string?
For reading from a table with a dynamic where statement you can refer to the question that was commented by Sandra Rossi.
To read from a dynamic field when you have a structure you can use assign component of structure to assign it to a field symbol.
If you have a structure ls_str and a variable holding the fieldname lv_field the syntax looks like this:
data: begin of ls_str,
text1 type text50,
text2 type text50,
end of ls_str.
field-symbols: <fs> type any.
data: lv_field type char30 value 'TEXT1'.
assign component lv_field of structure ls_str to <fs>.