Finally the time has arrived where I can write the tip to end all tips about JCL variables in inline SYSIN. In z/OS version 2.1 it it possible, at last. This is the end of all kinds of work-around (for instance using inline REXX). And for once IBM has done a good job right from the start as it also works in JCL procedures!! If your installation has not yet migrated to z/OS version 2.1 then you should apply some pressure somewhere to get it done. This feature alone is enough to justify the upgrade. And here is an example on this little miracle:
The example is the well known history about how to delete a dataset in the most convenient way using JCL. If you want to recreate the dataset in a following step it is quite nice to use the same name. And then it is quite nice to have a JCL variable containing the dataset name. Just to make it a litte advanced IBM has decided that you need to specify a new statement called EXPORT with a parameter called SYMLIST where you specify which JCL vaiables that is available in inline SYSIN. Fortunately you can just write SYMLIST=* to specify that all JCL variables are available. For safety precautions I will recommend you to use EXPORT in the beginning of your JCL, because then you are sure that inline substitution works for all the JCL variables you might define in the following JCL. Just to complicate things you must also specify a new parameter on your SYSIN DD statement called SYMBOLS=JCLONLY, which activates the substitution of JCL variables in your inline SYSIN.
I have also tried the above example in a JCL procedure and it works! Here you also need to use both EXPORT and SYMBOLS=JCLONLY. I forgot to test whether it works for a JCL parameter variable. If it does not work you just define a JCL variable in your JCL procdure and assigns this variable the value of the JCL parameter.