0

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?

1
  • It can be done with FIELD-SYMBOL. For code need some more context, the code where it has to fit in. Commented Jun 27 at 11:52

1 Answer 1

1

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>.
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.