Question:When we compile and link a Cobol program, how does the LINKER program locates the sub-program (Called program) to be linked? By the PROGRAM-ID of the called program or by the member name (dsname) of the LOADLIB PDS.
For example the program that we are compiling contains this statement:
Now if 'ABC' is the PROGRAM-ID of the program to be called, than how actually the LINKER program willl locate the sub-program to be linked. Where will it search for?
if 'A' has to be the member name in the LOADLIB PDS, then what is the use of PROGRAM-ID?
More: That too how the same works in case of static and dynamic linking?
Joined: 22 Sep 2005 Posts: 104 Location: Concord, New Hampshire, USA.
PROGRAM_ID entry of subprogram is for source code referenceses.Once subprogam is compiled, object program is it's identity,ie.,the member name of it's object code.This holds good for both static and dynamic call. Note:Source member name can be different from object code's member name,this can be done by JCL.In case of static call,while linkeditting the subprogram's object member name is searched for in the given PDS.
Hope this helps...
This makes things clear. I am just listing point the outcome of the discussion below. Correct if required.
(1) Once compiled dsname (load lib member name) acts as the programs identity. This applies in case is static and dynamic linking. Program-Id dosent plays any role in this case.
(2) If the called programs is a built-in program (written within the calling program), as possible in case of COBOL-85. In such case program-id of subprograms acts as its identity.
(3) Source code and the object code of a program can have different dsnames.
Note: I have used dsname in this coversation which is actually the member name of a PDS (loadlib or sourcelib).