Page 1 of 2

Values from JCL to Cobol subroutine

PostPosted: Sat May 28, 2011 3:43 pm
by rambachi2000
Hi All,

How to pass values from JCl to cobol subroutine, if want to pass date value from JCL to subroutine without changing main program.

Re: Values from JCL to Cobol subroutine

PostPosted: Sat May 28, 2011 3:49 pm
by steve-myers
JCL communicates parameter data only to a "main" program. What you propose cannot be done.

Re: Values from JCL to Cobol subroutine

PostPosted: Sat May 28, 2011 5:03 pm
by BillyBoyo
Although you haven't said exactly what you want to do, one possibility would be to put the data your require into a dataset and then read that dataset in the sub-program. As Steve says, you can't specify PARM in the JCL and have your sub-program get access to it, unless the main-program specifically includes it on the USING of the CALL to the sub-program.

Re: Values from JCL to Cobol subroutine

PostPosted: Sat May 28, 2011 5:21 pm
by rambachi2000
Can we pass the data through sysin card in JCL to subroutine..?

Re: Values from JCL to Cobol subroutine

PostPosted: Sat May 28, 2011 5:26 pm
by Robert Sample
Use ACCEPT.

Re: Values from JCL to Cobol subroutine

PostPosted: Sat May 28, 2011 5:28 pm
by BillyBoyo
Yes. SYSIN is just a DD statement. If your main-program is not reading SYSIN, then your sub-program could.

However, things would be much clearer for maintenance if you create a new DD for your sub-program to read. People won't expect SYSIN to be read in a sub-program, so will waste time investigating why it is in the JCL and not used by the main-program, then remove it from the JCL and have the sub-program not work.

Re: Values from JCL to Cobol subroutine

PostPosted: Sat May 28, 2011 6:00 pm
by rambachi2000
thanks Billy, Robert and Steve

Re: Values from JCL to Cobol subroutine

PostPosted: Sat May 28, 2011 6:15 pm
by rambachi2000
if subroutine is using 10 times in the same main program then how to code sysin card in jcl..?
do I need to repeat the values 10 times in sysin..?

Re: Values from JCL to Cobol subroutine

PostPosted: Sat May 28, 2011 6:37 pm
by enrico-sorichetti
then it would be wise to organize the subroutine in order to read the parameters only once

Re: Values from JCL to Cobol subroutine

PostPosted: Sat May 28, 2011 9:32 pm
by BillyBoyo
rambachi2000 wrote:if subroutine is using 10 times in the same main program then how to code sysin card in jcl..?
do I need to repeat the values 10 times in sysin..?


No, as enrico has said. In the sub-routine, only read the data (you have, unwisely to my mind, chosen to go with SYSIN) once, then store it for use that time and the remaining times that the sub-routine is called.