COBOL Subroutines



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

COBOL Subroutines

Postby hvats83 » Thu Dec 20, 2012 11:44 am

Please suggest if there is any way to refer working storage variables of subprogram in main program.
hvats83
 
Posts: 18
Joined: Mon Dec 05, 2011 11:57 am
Has thanked: 1 time
Been thanked: 0 time

Re: COBOL Subroutines

 

Re: COBOL Subroutines

Postby BillyBoyo » Thu Dec 20, 2012 12:35 pm

Why would you want to do that?

If you have some "result" that the sub-program has produced, you'd MOVE it to a Linkage Section item, defined in the main program specifically for that purpose, and given good names so you know what it is being used for.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: COBOL Subroutines

Postby hvats83 » Thu Dec 20, 2012 2:57 pm

There is a client business value copybook(used to set certain conditions in our system which differs for each customers.Every time we make change to program using this copybook we need to compile the source code every time(by giving copylib order).

Hence to reduce this effort I am trying to write a subroutine which will use this copybook and set the required conditions and main program can refer to working storage variable of sub program.This subprogram will be called dynamically(so that whenever we make change to main program no need to compile sub program)
hvats83
 
Posts: 18
Joined: Mon Dec 05, 2011 11:57 am
Has thanked: 1 time
Been thanked: 0 time

Re: COBOL Subroutines

Postby BillyBoyo » Thu Dec 20, 2012 4:09 pm

So, you call the sub-program with the 01 on the USING. MOVE from the Working-Storage in the sub-program to the 01 defined in the Linkage and on the USING of the Procedure Division.

Even better, define the data on a dataset. Read the dataset. No need to compile anything. Just an application to maintain the dataset.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: COBOL Subroutines

Postby Robert Sample » Thu Dec 20, 2012 5:46 pm

Directly refer to it? No -- this violates all rules of modular programming as well as creating nightmares for debugging, and if the subprogram is dynamically called it may not even be possible (when the calling program issues a CANCEL for example).

Indirectly refer to it? Yes -- use the LINKAGE SECTION variables and have the subprogram move data to and from the LINKAGE SECTION varaibles as appropriate.
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


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post