Compiler option used in CALL program



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

Compiler option used in CALL program

Postby tjegan » Thu Jun 18, 2015 4:17 pm

Hi ,

I have the below queries in COBOL subprogram concepts. Can anyone please get back to me with the answers.

1. Why do we use the compiler option(DYNAM/NODYNAM) only in Main program(Calling program)?
2. Why can't we use the same in Sub program(Called program)? What is the impact of including the compiler option(DYNAM/NODYNAM) in sub program.

Thanks in advance
tjegan
 
Posts: 33
Joined: Mon Mar 25, 2013 5:58 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Compiler option used in CALL program

Postby BillyBoyo » Thu Jun 18, 2015 4:27 pm

Specifying DYNAM or NODYNAM only affect CALL when used with 'literal'. Other than for the CALL statement, there is no impact on anything, and the impact only occurs with this type of CALL, not with CALL data-name (which can only be a dynamic CALL, and is not affected by the compiler option).

Either DYNAM or NODYNAM is specified in the compile of every program.

From your questions, I doubt this is the answer you expect, but it is the answer.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Compiler option used in CALL program

Postby tjegan » Fri Jun 19, 2015 11:03 am

Thanks for your response.
So these compiler option (DYNAM/NODYNAM) is only applicable for the main program ?

Please correct me if i am wrong.
tjegan
 
Posts: 33
Joined: Mon Mar 25, 2013 5:58 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Compiler option used in CALL program

Postby BillyBoyo » Fri Jun 19, 2015 12:20 pm

They are only applicable to a CALL statement. It is perfectly possible and common that a sub-program also uses CALL, and also possible that a "main" program doesn't use CALL.

Bear in mind that there is nothing "special" about a "main" program in COBOL. It can also run as a sub-program.

Make a very small program, with just ID DIVISION with PROGRAM-ID and PROCEDURE DIVISION.

In the PROCEDURE DIVISION CALL your "main" program and then GOBACK.

You "main" program will run as a sub-program, with no problems. It may not return to the CALLer (if STOP RUN has been used) but that does not make it "main", as STOP RUN can be used in a sub-program anyway.

We don't have "main" programs, just a program that happens to be the one on the EXEC statement on the step card in the JCL.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post