So far I have avoided to create my own JCL procedures. I did not feel the need for it and they seem to have limited functionality. Despite this most installations use a lot of JCL procedures. In the old days there were even a requirement for JCL procedures to be located in predefined libraries. Fortunately much of all this is not true any more and lately I have seen some of the light. This tip is dedicated to those of you who have not seen the light at all.
There are two kinds of JCL procedures. One is called inline JCL procedures and the other is genuine JCL procedures being accessible across different jobs. An inline JCL procedure only works within the job where it is defined. In my view it has another huge disadvantage, because it must be defined in front of the JCL where the inline JCL procedure is used. In other words you cannot define your steps at the top of your job and the JCL procedure at the bottom. This is the main reason for me to recommend you to use genuine JCL procedures right from the start as it is remarkable simple.
Let me show you an example. Let us start with a JCL procedure:
You save this JCL procedure in a member in your usual JCL library. The name of the member is the name of the JCL procedure. The first line in the member must be a PROC JCL card. A name is optional. After PROC you can specify parameters to be transferred to the JCL procedure. Transferring parameters to a JCL procedure is in my view what makes JCL procedures interesting. In this example I have only defined one parameter (MYPARM=). If this parameter is not specified on invocation it will be empty. Further parameters are separated by commas and a parameter can be assigned a default value (MYPARM2=MYINITVALUE).
After the PROC card you specify your steps. You can use a parameter almost anywhere in the JCL. Unfortunately a JCL procedure cannot contain inline SYSIN (it is available in z/OS version 1.13), and when it can, you cannot use a parameter in the data part of the inline SYSIN, which is quite annoying. In this example I use my single parameter as a dataset name and I use it twice to perform a good old compress of a member dataset (a PDS). The terminating PEND JCL card is optional and if you specify it, the name has no relevance.
The JCL procedure is simply invoked from your job like this (I have as usual omitted the JOB card):
In front of the first step where you want to use your JCL procedure you must specify a JCLLIB JCL card. The name has no relevance and may be omitted. After ORDER= you specify the name of your JCL library. You can specify more than one JCL library and it will work like a concatenation on a DD card. In this case you must separate each dataset name by a comma and put all the names in a parenthesis.
The job in this example will carry out the JCL procedure MYPROC in MY.JCL.LIBRARY twice. The first step will compress the dataset MY.PROGRAM.LIBRARY and the second step will compress MY.LOAD.LIBRARY. It is a very small job and it is very easy to change and extent.