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

rcursion in abap

Former Member
0 Likes
533

hi experts

i have this form:

form fill_tab using l_line_num

l_data.

DATA: l_datum TYPE datum,

l_erzet TYPE erzet,

l_dat1 TYPE string,

l_dat2 TYPE string.

CASE l_line_num.

WHEN '1'.

WHEN '2'.

wa_dat_dlv-delv_num = l_data.

WHEN '3'.

CONCATENATE l_data4(4) l_data2(2) l_data(2)

INTO wa_dat_dlv-delv_date.

wa_dat_dlv-delv_time = l_data+8.

WHEN '4'.

wa_dat_dlv-paz_ord_num = l_data.

WHEN '5'.

CONCATENATE l_data4(4) l_data2(2) l_data(2)

into wa_dat_dlv-order_date.

WHEN '6'.

wa_dat_dlv-cust_num = l_data.

WHEN '7'.

wa_dat_dlv-cust_desc = l_data.

WHEN '8'.

wa_dat_dlv-line_num = l_data.

WHEN '9'.

wa_dat_dlv-matnr = l_data.

WHEN '10'.

SPLIT l_data AT ' ' INTO l_dat1 l_dat2.

wa_dat_dlv-ord_amnt = l_dat1.

wa_dat_dlv-sup_amnt = l_dat2.

WHEN '11'.

wa_dat_dlv-u_o_m = l_data.

APPEND wa_dat_dlv TO it_dat_dlv.

WHEN OTHERS.

l_line_num = l_line_num - 4.

PERFORM fill_tab USING l_line_num l_data.

ENDCASE.

endform. " fill_tab

this form is a recursive form after l_line_num is greater than 11, when it happens l_line_num is updated to

l_line_num -4 and it calls the form again. but than the case don't stop.

what's the problem?

thank you

amit

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
505

define the interface variable l_line_num in changing mode because value has been chnging while exiting from the sub-routine

dont forgot to reward points for helpful answers

Regards,

Surya

3 REPLIES 3
Read only

Former Member
0 Likes
506

define the interface variable l_line_num in changing mode because value has been chnging while exiting from the sub-routine

dont forgot to reward points for helpful answers

Regards,

Surya

Read only

0 Likes
505

surya thanks

but it didn't solved the problem

amit

Read only

0 Likes
505

I don´t know in which context you use this FORM routine, but, when using recursions it is extremely important to carefully define an exit condition to stop the recurssion. Otherwise you will end up in an endless recursion...

You do not have an exit condition at all. In your case, the FORM routine is called over and over again.