Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

deep structure - assign component

Former Member
0 Likes
1,767

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

1 ACCEPTED SOLUTION
Read only

former_member186741
Active Contributor
0 Likes
717

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.

2 REPLIES 2
Read only

Former Member
0 Likes
717

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.

Read only

former_member186741
Active Contributor
0 Likes
718

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.