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 loop

Former Member
0 Likes
1,423

Hello,

What is the best way to set up a recursive loop in ABAP? Can I call FM from itself?

Material1 depends on material2 , material 2 depends on materials3 & materials4 (this is not BOM).

Thanks

9 REPLIES 9
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,231

Hi,

Can you please explain a bit more clear on your requirement.

I guess if you asking to improve performance in a nested loop, then refer the below:-

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/40729734-3668-2910-deba-fa0e95e2c....

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
1,231

my requirement is to build a hieararchy of components used in production process. This hierarchy is different from BOM.

material1 was produced by production order1 using components 11, 12, 13...

Component11 was produced by production order11 using components 111, 112, 113

The output should look like as follows :

material1 01

component11 0101

component111 010101

component112 010102

Read only

0 Likes
1,231

recursive function modules are allowed, but i would prefer writing classes/methods.They can be used recursive, too.

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,231

Hi,

So do you want to use only one loop statement, and use it recursively to collect the data?

Please clarify.

Regards,

Tarun

Read only

Former Member
0 Likes
1,231

thanks

Can somebody give me an example how the code could look like

I am not that experienced in ABAP

Read only

Former Member
0 Likes
1,231

thanks

not necesarily , waiting for guru recommendations

Read only

0 Likes
1,231

Its like all other languages. You just need to call a Fm inside a FM.

Read only

Former Member
0 Likes
1,231

Using a while statement gives a good recursive solution for ur condition...

Callin a FM within a FM is also a great option with conditions properly taken of...

Hope this helps!!

Kanchan

Read only

Former Member
0 Likes
1,231

no answer