Recursion In Cobol



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Recursion In Cobol

Postby pcdoctor » Thu Feb 28, 2008 10:26 pm

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)
pcdoctor
 
Posts: 17
Joined: Mon Feb 18, 2008 10:21 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Recursion In Cobol

Postby CICS Guy » Thu Feb 28, 2008 10:52 pm

How about Making recursive calls in the fine programming guide?
CICS Guy
 
Posts: 246
Joined: Wed Jun 20, 2007 4:08 am
Has thanked: 0 time
Been thanked: 0 time

Re: Recursion In Cobol

Postby pcdoctor » Thu Feb 28, 2008 11:00 pm

@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
pcdoctor
 
Posts: 17
Joined: Mon Feb 18, 2008 10:21 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Recursion In Cobol

Postby dick scherrer » Fri Feb 29, 2008 12:38 am

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Recursion In Cobol

Postby pi17388 » Fri Feb 29, 2008 6:58 am

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.
pi17388
 
Posts: 6
Joined: Tue Feb 19, 2008 9:33 pm
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post