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

Form Routine calling itself

Former Member
0 Likes
520

I would like to know what the perfomance issues if any the following code would cause:

select single matnr

from mean

into lv_matnr

where ean11 = lv_ean11

and eantp = 'UC'. "#EC *

if sy-subrc = 0. " If Same UPC existed / assigned to material then generate next UPC number

perform GET_NEXT_NUMBER. " Get Next number in the same number range

else.

V_UPC = lv_upc_chk.

endif.

The issue is that this code is in the form routine GET_NEXT_NUMBER and if the select to MEAN is successful it calls itself. If this happens many times wouldn't this have a negative effect on performance?

3 REPLIES 3
Read only

former_member191735
Active Contributor
0 Likes
482

>

> I would like to know what the perfomance issues if any the following code would cause:

>

> select single matnr

> from mean

> into lv_matnr

> where ean11 = lv_ean11

> and eantp = 'UC'. "#EC *

> if sy-subrc = 0. " If Same UPC existed / assigned to material then generate next UPC number

> perform GET_NEXT_NUMBER. " Get Next number in the same number range

> else.

> V_UPC = lv_upc_chk.

> endif.

>

> The issue is that this code is in the form routine GET_NEXT_NUMBER and if the select to MEAN is successful it calls itself. If this happens many times wouldn't this have a negative effect on performance?

Unless you change lv_ean11 - This will be endless loop. Forget about performance but think about getting out from the routine.

if the value is changed then that is ok if it serves the purpose. This is a recursive call and cannot be eliminated if required.

Read only

0 Likes
482

Agreed. I should have included the code above this section where the NUMBER_GET_NEXT FM is called to build the next lv_ean11(UPC number) value used in the select. This process will continue until a matching UPC number is not found in MEAN.

Read only

0 Likes
482

that's alright, If you cannot eliminate the recursive call. as far as i know, there is no alternate to recursive