Page 1 of 1

Recursion In Cobol

PostPosted: Thu Feb 28, 2008 10:26 pm
by pcdoctor
How can we invoke recursiveness in a cobol program???I dont mean using goto or perform..I would like to implement a cobol pgm which would call itself..Pls help..(Simple application would be to calculate factorial)

Re: Recursion In Cobol

PostPosted: Thu Feb 28, 2008 10:52 pm
by CICS Guy
How about Making recursive calls in the fine programming guide?

Re: Recursion In Cobol

PostPosted: Thu Feb 28, 2008 11:00 pm
by pcdoctor
@CicsGuy
I went thro the material but still not clear..
My requirement is that i have to make a pgm call itself and when it is calling itself the data in linkage section must be used..so i wonder as to how to make my pgm recursive i.e how to make it call itself..in my case called pgm and calling pgm is same..It would be very clear to me if you can post some examples(syntax) implementing this..
Thanks in Advance

Re: Recursion In Cobol

PostPosted: Fri Feb 29, 2008 12:38 am
by dick scherrer
Hello,

I went thro the material but still not clear..
What part of the material was not clear? If the manual is not clear to you, i'd suggest maybe looking at a different way to implement your requirement.

Is there some business reason that your code needs to call itself or might you accomplish the same thing by using some array(s)?

We don't have any sample/pseudo code, but if you search the web for "bill of materials processing" (BOMP), you will find multiple examples. BOMP processing has been around for a long, long time.

Re: Recursion In Cobol

PostPosted: Fri Feb 29, 2008 6:58 am
by pi17388
depending on the specific language environment/runtime libraries in use (OS/VS Cobol; VS Cobol II, IBM Cobol; Enterprise Cobol) you will need to use compiler options (RENT and REUS). The combination (or lack thereof) is dependent on the specific runtime environment and compiler version. Reentrant COBOL code has been around for quite a while in the CICS transaction environment so you should be able to find a number of examples via web searches.