Manage Learn to apply best practices and optimize your operations.

JCL procedure tips

If you write your own JCL, these input and output tips will make coding and calling procedures a little easier.

By Robert Little

To those of you who still code your own JCL and - shudder - put the JCL into procedures for your own or others' use, here are a couple of tips that might make coding and calling procedures a little easier.

Did you ever have a situation in which you created a procedure containing two different parameters that had the same value about 90% of the time but different values the other 10%? So, whenever you called the procedure, you had to pass the same two values into the two parameters most of the time. Wouldn't it be nice to pass one parameter most of the time and only pass two parameters when you needed to? Here is a simple tip that allows you do to this.


The Compress Procedure Example (listed below) takes an input data set and terses (compresses) it using an IBM-supplied utility. The output from this procedure is a compressed data set. The input data set is not changed.

The procedure can be passed either one parameter (the input data set name) or two parameters (the input data set name and the output data set name). If passed one parameter, the procedure uses the input data set name to build the output data set name. The output data set name is the input data set name with the node ".TERSED" appended to the end. This is how the procedure would be called most of the time (the 90% case).

However, there are some cases where you would not be able to do this (the 10% case). For example, if the input data set name was more than 37 characters long, appending ".TERSED" to it would result in a data set name that contained too many characters, and a JCL error. In this case, we would need to pass two parameters to the procedure: the input data set name and the output data set name. The procedure would take the output data set name and append ".TERSED" to it, so the output data set name must contain fewer than 38 characters.

The trick here is to use the input data set name parameter as a default value for the output data set name in the procedure header definition. Then when the procedure gets expanded, if no output data set name is passed to the procedure, it will use the value passed as the input data set name.

Did you ever have a situation where you needed to execute a TSO command against a data set within JCL? You could call program IKJEFT01 (the TSO command processor) within the JCL and hard-code the TSO command inline after the SYSIN DD statement. But what if you wanted to code this step within a procedure and pass the name of the data set within a procedure parameter? You cannot have inline control statements within your procedure. And even if you could, you could not specify a procedure parameter within the statements because no substitution would be performed.

You can call program IKJEFT01 within your JCL and code the command to be executed within the PARM field. This field can contain procedure parameters and substitution of the parameters will be performed. After the substitution has been done, the resulting string is passed to the TSO command processor and executed. The TSO Command Procedure Example (listed below) shows how to rename a data set within a procedure step.

There are many other not so obvious ways to do things within procedures. I would suggest that, if you think there ought to be a way to do something, there probably is. It just requires a little bit of imagination and a lot of trial and error to find it.

 Code: COMPRESS PROCEDURE EXAMPLE //JOBCARD //* //********************************************************************* //* * //* TERSE (COMPRESS) THE DATA SET ALLOCATED TO DDNAME "INFILE" * //* INTO THE DATA SET NAME ALLOCATED TO DDNAME "OUTFILE". * //* * //********************************************************************* //* //TERSE PROC INFILE=DEFAULT, // OUTFILE=&INFILE //* //TERSE EXEC PGM=TRSMAIN,PARM='PACK' //* //STEPLIB DD DISP=SHR,DSN=SYS1.LOADLIB LIBRARY CONTAINING TRSMAIN //* //SYSPRINT DD SYSOUT=* //* //INFILE DD DISP=SHR, // DSN=&INFILE //* //OUTFILE DD DISP=(NEW,CATLG,DELETE), // LRECL=1024,DSORG=PS,RECFM=FB, // UNIT=SYSDA,SPACE=(CYL,(500,100),RLSE), // MGMTCLAS=MCTSO,STORCLAS=SCBASE, // DSN=&OUTFILE..TERSED //* //* //********************************************************************* //* * //* EXECUTE JCL TO CALL PROCEDURE TERSE WITH ONE PARAMETER. * //* * //********************************************************************* //* //LIST01 EXEC TERSE,INFILE='USERID.PM12345.LIST01' //* //* //********************************************************************* //* * //* EXECUTE JCL TO CALL PROCEDURE TERSE WITH TWO PARAMETERS. * //* * //********************************************************************* //* //*SVCDMP01 EXEC TERSE, //* INFILE='MVS.DUMP.E.JOBNAME.D020804.T020646.S00031', //* OUTFILE='USERID.PM12345.SVCDMP01' TSO COMMAND PROCEDURE EXAMPLE //JOBCARD //* //********************************************************************* //* * //* PROCEDURE TO RENAME A DATA SET. * //* * //********************************************************************* //* //RENAME PROC OLDFILE=, // NEWFILE= //* //* //RENAME EXEC PGM=IKJEFT01, // PARM='RENAME ''&OLDFILE'' ''&NEWFILE''' //* //SYSPRINT DD SYSOUT=* //* //SYSTSPRT DD SYSOUT=* //* //SYSTSIN DD DUMMY //* //* //RENAME PEND //* //* //********************************************************************* //* * //* EXECUTE JCL TO CALL PROCEDURE RENAME. * //* * //********************************************************************* //* //RENAME EXEC RENAME,OLDFILE='USERID.OLD.FILE', // NEWFILE='USERID.NEW.FILE'

Comments? Questions? Email us at or email Robert Little.

Dig Deeper on IBM system z and mainframe systems

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.