| Q. What is a JCL PROC(Procedure)? | |||||||||||||||||||||||||||||||||
| In JCL, we have an important concept of re-usability in the form of Instream and Cataloged Procedures. Once a Batch Job(a group of job-steps in JCL) have been written, you can give this JCL a name and save it onto Secondary Storage. Whenever you need to run the same procedure again, you can simply call it/refer to it by its name, instead of having to rewrite the entire JCL source code again. Thus, if you give your JCL a name, and make it available for others, a third person, who requires the same functionality, can simply call you JCL, and use it like a ready-made object. He doesn’t need to reinvent the wheel all over again. Note that : This is analogous to writing Function(Procedure or Method) in most conventional/traditional programming languages. | |||||||||||||||||||||||||||||||||
| Q. What is a Cataloged Procedure? | |||||||||||||||||||||||||||||||||
Lets say, we’ve written the following JCL PROC.
The above PROC can be saved either in a user-defined library(PDS), or in the Default SYSTEM LIBRARY. The Default System-defined Library is SYS1.PROCLIB. So, if we would like anybody to use our JCL PROC globally, we must make sure it is universally visible, by placing it under the Default System Library. We can now call this PROC as follows:
Note, here the while executing MYPROC, it will first search any user-defined private libraries. Since, this Batch Job does not specify any user-defined private library, it will now search for MYPROC in DEFAULT System Library - SYS1.PROCLIB. If we had saved the above PROC MYPROC as a member in our own user-defined private library like TRGD56.DEMO.PROCLIB(MYPROC), then the above JCL would look as follows -
Thus, to specify a user-defined private library, we must use JCLLIB statement. Analogy with respect to conventional Programming Languages like Java and C# : This is the same as when referring to a class/object(containing variables and methods) in a package in Java, or in a namespace in C-Sharp. We need to specify the name of the package using import statement in Java or the using keyword in C#. The JCLLIB of JCL is equivalent to using in C#, or import in Java, or #include in C,C++. | |||||||||||||||||||||||||||||||||
| Q. What is an Instream Procedure? | |||||||||||||||||||||||||||||||||
An Instream Procedure is a PROC written as a part of the same JCL/Batch JOB, and referred to elsewhere in the Batch Job. Let me cite to you, a simple example of how an Instream PROC is used wherever needed at other placed in the Batch Job.
In the above JCL, I’ve called the instream procedure MYINPROC twice, once in STEP02 and second in STEP04. The maximum number of Instream PROCs you can write in a Batch JOB is 15. More on Cataloged Procedures – Overriding Parameters >> | |||||||||||||||||||||||||||||||||
| Note : You cannot code Instream Datasets in Cataloged Procedures. So, in cataloged Procedure DD * statement is not allowed. |
Example of calling a PROC
Main JCL/Batch JOB – Calling Program
Called Procedure – Member MYPROC stored in the default system Library SYS1.PROCLIB
Output – Contents of the Dataset HERC03.DEMO.MYLIB(INPUT) are printed to default printer :
THIS IS DD STATEMENT IN CALLED PROGRAM.


0 comments:
Post a Comment