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

    Requires Free Membership to View

(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 SearchDataCenter.com or email Robert Little.

This was first published in November 2008

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.