Page 1 of 1

Subroutines: calling program or a called program

PostPosted: Tue Jan 17, 2012 5:20 pm
by reebahs
Hi All,

I have a query in Cobol Subroutines.

How can we differentiate a program as a calling program or a called program ?

Suppose I have 3 Applications Programs say A, B, C.

Program A is calling B.
Program B is calling C.
If I give Program B to a you, How can you Identify whether it is calling/called program ?

Thanks In Adv,
Reebahs.

Re: Subroutines

PostPosted: Tue Jan 17, 2012 5:34 pm
by BillyBoyo
Assuming that some data is made available to Prog B, there will be a Linkage Section and a USING on the PROCEDURE DIVISION.

Prog A might have the same, to process a PARM (specified in the JCL) but the definition of the item in the Linkage Section would be specific (two-byte binary containing length of data, followed by the data itself).

You could write a main program so that it looked like a sub-program, and vice versa, but we'd avoid doing it. If in doubt, consult the documentation of the system which is using the program.

Re: Subroutines

PostPosted: Tue Jan 17, 2012 8:55 pm
by Robert Sample
You identify calling programs by looking at the compile output (source won't work since the CALL could be in a copy book that gets pulled in during the compile) for the word CALL.

As Billyboyo said, you identify called programs by the USING on the PROCEDURE DIVISION statement and LINKAGE SECTION items -- unless the program is called without any data being passed to it, in which case you cannot know if the program is called from another program without doing some kind of run-time trace of calls.

Re: Subroutines: calling program or a called program

PostPosted: Thu Jan 19, 2012 8:34 pm
by reebahs
Got It......
ThankQ BillyBoyo and Robert Sample for clarifying.

Reg,
Reebahs.