On Tue, Aug 9, 2016 at 9:40 AM, John McKown <[email protected]> wrote:
> This is a kind of curiosity question. Unless a COBOL program is compiled > with the THREAD option and the RECURSIVE clause on the PROGRAM-ID, the > program cannot CALL itself. I have also found out that if you use an ENTRY > statement and the compile NAME(ALIAS), you cannot do a CALL of the alias > from the "main" program either. E.g. if you have a PROGRAM-ID. A. and an > ENTRY 'B', then you cannot CALL 'B' while running A. I am thinking this > must be in some way related to the fact that 'A' and 'B' share the same > WORKING-STORAGE area. But I was just wondering if anybody knows how this is > implemented. Of course, it is probably likely to change between releases, > so it's not something I could depend on. > > Why the interest? Because while talking with Chuck Hardee about having an > LE condition handler in the same source member (as an ENTRY) as the main > COBOL routine, we found that the run-unit will abend with a U4087-2 and > some messages about recursive invocation. So as a test, I compiled a sample > which got the U4087-2 with the THREAD option and RECURSIVE clause, and that > ran successfully. However the THREAD option comes with some possibley nasty > side restrictions. In particular, no INITIAL clause in the PROGRAM-ID > sentence and, worse, no use of SORT / MERGE verbs. > Well, here I am talking to myself again. At least I'm not, yet, into the 3 way arguments with myself. But it turns out that I misread the manual. RECURSIVE is required on the PROGRAM-ID if THREAD is used, but not vice versa. So it appears that all I really need is the RECURSIVE clause on the PROGRAM-ID and not the THREAD compile option. But I'm still mildly curious about how COBOL detects recursion, if you know off-hand. -- Klein bottle for rent -- inquire within. Maranatha! <>< John McKown ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
