Skip to Content
0
Former Member
Sep 28, 2013 at 09:07 PM

Get the value dynamically from internal table

153 Views

Hello expert,

I have one strcture defined which has fields = field01, field02 , field03, field04, field05, ..... field100

Data: ls_field type <structure type>

lt_field type table of ls_field.

data: lv_fieldName type string. // hold the value of field name .. field01 or field02 or field03 or ..... field100

I am passing 01, 02, 03 .... as input

so my lv_fieldname will be = field01 or field02 or field03.

for exaple, lv_fieldName = 'field02'.

Now, I am looping table lt_field. which is populated.

Loop lt_field into ls_field.

write ls_field-lv_fieldName .

// program is giving error at this point... my question is , i want to get the value dynamically based on string ( lv_fieldName) but lv_fieldName is not part of the structure. so its giving me error.....

Correct way is write ls_field-field01. // can we reference the field name dynamically to get th values.

endLoop.