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

Recursive call

Former Member
0 Likes
1,396

Hi Experts,

In my program recursive call was used. that perform will call upto infinite time running,

I am using this is first time can u plz help. I given below code.

LOOP AT i_orgeh INTO wa_orgeh.

PERFORM set_node_level USING wa_orgeh-orgeh 0.

ENDLOOP.

FORM set_node_level USING

fp_orgson TYPE ty_orgeh_rel-orgson

fp_level TYPE ty_orgeh_rel-level.

DATA : l_1levelup TYPE ty_orgeh_rel-level.

LOOP AT i_orgeh_rel INTO wa_orgeh_rel

WHERE orgson = fp_orgson.

IF fp_level < wa_orgeh_rel-level.

wa_orgeh_rel-level = fp_level.

MODIFY i_orgeh_rel FROM wa_orgeh_rel

INDEX sy-tabix

TRANSPORTING level.

ENDIF.

l_1levelup = fp_level + 1.

v_1levelup = l_1levelup.

PERFORM set_node_level USING fp_orgson l_1levelup.

ENDLOOP.

ENDFORM. " SET_NODE_LEVEL

11 REPLIES 11
Read only

Former Member
0 Likes
1,354

Hi,

U are calling form within form defintion also,give a condition to exit.

Read only

viquar_iqbal
Active Contributor
0 Likes
1,354

hi

In the form use if sy-subrc ne 0 .

exit.

endif.

so it will exit.

Thanks

Viquar Iqbal

Read only

Former Member
0 Likes
1,354

Hi,

LOOP AT i_orgeh INTO wa_orgeh.
PERFORM set_node_level USING wa_orgeh-orgeh 0 sy-tabix.
ENDLOOP.

FORM set_node_level USING
fp_orgson TYPE ty_orgeh_rel-orgson
fp_level TYPE ty_orgeh_rel-level
fp_tabix type sy-tabix.

DATA : l_1levelup TYPE ty_orgeh_rel-level,
l_tabix like sy-tabix.

LOOP AT i_orgeh_rel INTO wa_orgeh_rel FROM fp_tabix
WHERE orgson = fp_orgson.

IF fp_level < wa_orgeh_rel-level.
wa_orgeh_rel-level = fp_level.

MODIFY i_orgeh_rel FROM wa_orgeh_rel
INDEX sy-tabix
TRANSPORTING level.
ENDIF.

l_1levelup = fp_level + 1.
v_1levelup = l_1levelup.

PERFORM set_node_level USING fp_orgson l_1levelup l_tabix.

ENDLOOP.

ENDFORM. " SET_NODE_LEVEL

This should not give an infinite call to recursion... please check.

if its changing the requirement then please do let us know about the requirement.... with example.

Regards,

Siddarth

Read only

0 Likes
1,354

Hi siddarth,

As per you send that code also giving same problem. If yuou have any idea plz help me.

Read only

0 Likes
1,354

Hi ,

I am geting problem in " IF fp_level < wa_orgeh_rel-level." this condition.

Thanks

Srinu

Read only

0 Likes
1,354

Hi,

I tried finding out the reason, but unable to as i dont have the table fields and other things,

if possible would you please paste the whole code so that I can look into it and then give you the right solution of it...

Regards,

Siddarth

Read only

0 Likes
1,354

Hi siddarth,

can u give me u r mail id. i will sent code. that is better for us.

Read only

0 Likes
1,354

Hi,

I think it would be better if we can do this in forum as it would be against the rule of the sdn forum...

you can paste the code here, or code which ever is necessary to run and get the desired result and also please tell me the exact requirement as well

Regards,

Siddarth

Read only

Former Member
0 Likes
1,354

Hi Srinu ,

you please try this -


* LOOP AT i_orgeh INTO wa_orgeh.                       " Comment that
PERFORM set_node_level USING wa_orgeh-orgeh 0.
*ENDLOOP.                                                         " Comment that

FORM set_node_level USING
fp_orgson TYPE ty_orgeh_rel-orgson
fp_level TYPE ty_orgeh_rel-level.

DATA : l_1levelup TYPE ty_orgeh_rel-level.

LOOP AT i_orgeh_rel INTO wa_orgeh_rel
WHERE orgson = fp_orgson.

IF fp_level < wa_orgeh_rel-level.
wa_orgeh_rel-level = fp_level.

MODIFY i_orgeh_rel FROM wa_orgeh_rel
INDEX sy-tabix
TRANSPORTING level.
ENDIF.

l_1levelup = fp_level + 1.
v_1levelup = l_1levelup.

If sy-index = 1.                                      " Add this line
PERFORM set_node_level USING fp_orgson l_1levelup.      
endif.                                                   " Add this line
ENDLOOP.

ENDFORM. " SET_NODE_LEVEL

Thanks and regards

Pinaki

Read only

Former Member
0 Likes
1,354

Any organization has only few levels .. say upto 10 or 20 levels (top or bottom) .. please check how

many levels are there in your org ..

else there is some error in picking up of data in your internal table "i_orgeh"

check as below ..

if l_1levelup > some_number.

exit.

endif.

Read only

Former Member
0 Likes
1,354

thanx