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

Performance hit with 'ASSIGN COMPONENT'

Former Member
0 Likes
1,382

Hi,

I am using 'Assign Component' to pass values between 2 dynamically created tables. However it seems the subroutine where this is occuring is taking long to run.

Is ASSIGN COMPONENT abc of STRUCTURE .... statement Performance intensive ?

Thanks

1 ACCEPTED SOLUTION
Read only

franois_henrotte
Active Contributor
0 Likes
1,113

be sure to do ASSIGN only once, not each pass in your LOOP

7 REPLIES 7
Read only

franois_henrotte
Active Contributor
0 Likes
1,114

be sure to do ASSIGN only once, not each pass in your LOOP

Read only

0 Likes
1,113

Thanks. The component to assign is inside a Loop.

Loop at itab

Assign Component itab-comp of structure struc..

Endloop.

itab has the name of the components (fields) of the structure.

Read only

0 Likes
1,113

I'm not sure if using the INDEX of the field of the structure is faster than using the name of the field or not. Maybe you can try it.

Regards,

Rich Heilman

Read only

franois_henrotte
Active Contributor
0 Likes
1,113

if you can give the complete code between LOOP and ENDLOOP we could see if optimization is possible...

Read only

0 Likes
1,113

Hi Francois... Here is the code

Loop at <it_select_tab> assigning <ls_select_tab>.

INSERT INITIAL LINE INTO <it_select_global> index cnt assigning

<ls_select_global>.

Loop at ifc_local into xfc.

assign component xfc-fieldname of structure <ls_select_tab> to

<ls_select_field>.

read table itg_map into itl_map with key

zsyst = lv_syst

zmapfield = xfc-fieldname

binary search.

if sy-subrc = 0.

assign component itl_map-fieldname of structure

<ls_select_global> to

<ls_select_global_field>.

<ls_select_global_field> = <ls_select_field>.

endif.

Endloop.

Unassign: <ls_select_field>,

<ls_select_global_field>.

Endloop.

Read only

0 Likes
1,113

OK in this case you cannot do it else, but you should try to remove nested loops. For example, why don't you do the loop directly on itg_map in place of xfc ?

but anyway beware your UNASSIGN statements are not placed well, they should be placed like this:

Loop at ifc_local into xfc.

assign component xfc-fieldname of structure <ls_select_tab> to

<ls_select_field>.

read table itg_map into itl_map with key

zsyst = lv_syst

zmapfield = xfc-fieldname

binary search.

if sy-subrc = 0.

assign component itl_map-fieldname of structure

<ls_select_global> to

<ls_select_global_field>.

<ls_select_global_field> = <ls_select_field>.

UNASSIGN <ls_select_global_field>.

endif.

UNASSIGN <ls_select_field>.

Endloop.

Endloop.

Read only

0 Likes
1,113

Thanks Francois. It helped with the performance.