Subroutines: calling program or a called program



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

Subroutines: calling program or a called program

Postby reebahs » Tue Jan 17, 2012 5:20 pm

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.
reebahs
 
Posts: 28
Joined: Thu Dec 09, 2010 1:03 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Subroutines: calling program or a called program

 

Re: Subroutines

Postby BillyBoyo » Tue Jan 17, 2012 5:34 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Subroutines

Postby Robert Sample » Tue Jan 17, 2012 8:55 pm

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.
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

Re: Subroutines: calling program or a called program

Postby reebahs » Thu Jan 19, 2012 8:34 pm

Got It......
ThankQ BillyBoyo and Robert Sample for clarifying.

Reg,
Reebahs.
reebahs
 
Posts: 28
Joined: Thu Dec 09, 2010 1:03 pm
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post