Impact of calling sub-program twice in the calling program



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

Impact of calling sub-program twice in the calling program

Postby premv12 » Mon Jan 17, 2011 6:48 am

If a cobol program is called 2nd time from the same callng program, called program remains in the last used state. Is this true for Static call or for both static and dynamic call?
premv12
 
Posts: 7
Joined: Sat Dec 18, 2010 9:52 am
Has thanked: 0 time
Been thanked: 0 time

Re: Impact of calling sub-program twice in the calling program

 

Re: Impact of calling sub-program twice in the calling progr

Postby Robert Sample » Mon Jan 17, 2011 7:23 am

The Programming Guide manual tells you the answer in chapter 4.1.2:
A subprogram is usually left in its last-used state when it terminates with EXIT PROGRAM or GOBACK. The next time the subprogram is called in the run unit, its internal values are as they were left, except that return values for PERFORM statements are reset to their initial values. (In contrast, a main program is initialized each time it is called.)

There are some cases where programs will be in their initial state:


A subprogram that is dynamically called and then canceled will be in the initial state the next time it is called.

A program that has the INITIAL attribute will be in the initial state each time it is called.

Data items defined in the LOCAL-STORAGE SECTION will be reset to the initial state specified by their VALUE clauses each time the program is called.
Learning to use the manuals will allow you to answer this type of question yourself, much faster than a forum could.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post