‎2006 Mar 30 6:47 PM
hi,
I have a structure like:
data: begin of wa_xxx,
rec like bkpf,
iba(10) TYPE c,
bba(10) TYPE c,
END OF wa_xxx.
Now I would like to assign the strucutre like:
field-symbols: <fs_1> like wa_xxx
...
loop....
assign component sy-tabix of structure <fs_1> to <fs_2>.
...
endloop.
The first compoment is rec, but I need <fs_1>-rec-...(fields of the structure)
How can I do this? Any Idea?
thanks
markus
‎2006 Mar 30 11:15 PM
Hi Markus,
I'm not sure exactly what you mean but here's some code:
types: begin of ty_xxx,
rec like bkpf,
iba(10) TYPE c,
bba(10) TYPE c,
END OF ty_xxx.
data t type table of ty_xxx.
data d type ty_xxx.
field-symbols: <el> type any, <str> type ty_xxx.
you can assign the whole structure to a field-symbol...
loop at t assigning <str>.
you can refer directly to eleemnets within the filed-symbol structure...
if <str>-bba is initial. endif.
do.
you can loop through the individual components of the field symbol structure
assign component sy-tabix of structure <str> to <el>.
if sy-subrc <> 0.
exit.
endif.
you can operate on the current element within the structure
if <el> is initial. endif.
enddo.
endloop.
‎2006 Mar 30 6:53 PM
Markus,
I am not sure why you are going for complex approach here as the structure you have mentioned here is not a deep strcture, its a notmal work area.
I would suggest you use a INCLUDE STRUCTURE BKPF , so that you can directly use wa_xxx-fields from BKPF. That way you don't need to deal with it in a complex manner.
If my understanding is wrong, coule you please explain in detail.
A deep structure is one which has a internal table inside a internal table.
regards,
Ravi
Note : Please mark the helpful answers.
‎2006 Mar 30 11:15 PM
Hi Markus,
I'm not sure exactly what you mean but here's some code:
types: begin of ty_xxx,
rec like bkpf,
iba(10) TYPE c,
bba(10) TYPE c,
END OF ty_xxx.
data t type table of ty_xxx.
data d type ty_xxx.
field-symbols: <el> type any, <str> type ty_xxx.
you can assign the whole structure to a field-symbol...
loop at t assigning <str>.
you can refer directly to eleemnets within the filed-symbol structure...
if <str>-bba is initial. endif.
do.
you can loop through the individual components of the field symbol structure
assign component sy-tabix of structure <str> to <el>.
if sy-subrc <> 0.
exit.
endif.
you can operate on the current element within the structure
if <el> is initial. endif.
enddo.
endloop.