‎2006 Dec 15 6:16 AM
Hi all!
is it possible to access a field of an internal table using a variable.
for example, please see my code below.
DATA: BEGIN OF itab,
field1 LIKE mara-matnr,
field2 LIKE mara-matkl,
END OF itab.
data: v_fldname(5).
**- itab is being populated here -**
v_fldname = 'field1'.
**- i want to access the first field of itab, field1-**
***- but instead of doing this code
write itab-field1.
***- i want to do this...
write itab-(v_fldname).
but im getting an error message saying that <<The data object "IT_VAD" does not have a component called "">>
please send me the correct way to deal with this.
Thanks for your usual support.
‎2006 Dec 15 6:18 AM
Yes it is possible to achive what you want, not with variables but with Field symbols.
- Guru
Reward points for helpful answers
‎2006 Dec 15 6:18 AM
Yes it is possible to achive what you want, not with variables but with Field symbols.
- Guru
Reward points for helpful answers
‎2006 Dec 15 6:18 AM
im sorry, here's the correct error message:
The data object "itab" does not have a component called ""
‎2006 Dec 15 6:19 AM
‎2006 Dec 15 6:23 AM
I dont have a SAP sytem now but This is a sample.
Field-symbols f_field.
Assin a value to the field symbol
Assign f_field value "Field name"
Now the value "Field name" is stored in F_Field. You can use the value as below
v_somefield = <f_field>. " V_somefield will now have a value of "Field name"
- Guru
Reward points for helpful answers
‎2006 Dec 15 6:22 AM
try this it may help
FM name 'GET_COMPONENT_LIST'
DATA : components LIKE rstrucinfo OCCURS 0 WITH HEADER LINE.
*----
Get component list
CALL FUNCTION 'GET_COMPONENT_LIST'
EXPORTING
program = sy-repid
fieldname = 'ITAB'
TABLES
components = components.
regards
shiba dutta