Page 1 of 1

Compiler option used in CALL program

PostPosted: Thu Jun 18, 2015 4:17 pm
by tjegan
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

Re: Compiler option used in CALL program

PostPosted: Thu Jun 18, 2015 4:27 pm
by BillyBoyo
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.

Re: Compiler option used in CALL program

PostPosted: Fri Jun 19, 2015 11:03 am
by tjegan
Thanks for your response.
So these compiler option (DYNAM/NODYNAM) is only applicable for the main program ?

Please correct me if i am wrong.

Re: Compiler option used in CALL program

PostPosted: Fri Jun 19, 2015 12:20 pm
by BillyBoyo
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.