JCL, Define and use Variables
 Variable Substitution and SET Statement
http://www.simotime.com
When technology complements business    Copyright © 1987-2010  SimoTime Enterprises  All Rights Reserved
  Table of Contents Version 10.03.20 
  Introduction
  The SET Statement
  Variable Substitution with SET Statement Value
  A Sample Job using JCL
 
  A Sample JCL Member
  A Sample JCL Procedure
  Summary
 
  Software Agreement and Disclaimer
  Downloads and Links to Similar Pages
  Glossary of Terms
  Comments or Suggestions
  About SimoTime

Introduction
(Next) (Previous) (Table-of-Contents)

This suite of programs is a mainframe JCL example that will describe how to define (or name) a variable value and then use or change the variable by its referenced name.

The source code, data sets and documentation are provided in a single zipped file called JCLSUB01.ZIP. This zipped file may be downloaded from the SimoTime Web site.

The SET Statement
(Next) (Previous) (Table-of-Contents)

The SET statement is used to define a variable by name and set an initial value for the variable. The format of the SET statement is as follows.

....:....1....:....2....:....3....:....4....:....5....:....6....:....7.
//         SET DSNUT1=SIMOTIME.DATA.SUB998D1
//         SET DSNUT2=SIMOTIME.DATA.SUB100D1

The variable may then be referenced in subsequent Job Steps within the JCL member or within a PROC that is executed by the JCL member. To reference the variable simply precede the name with an ampersand (for example, &DSNUT1).

Variable Substitution with SET Statement Value
(Next) (Previous) (Table-of-Contents)

The preceding section described how to SET a value to a variable name. The following two statements show how to reference the variable by name. It is a simple matter of preceding the name with an ampersand.

//SYSUT1   DD  DSN=&DSNUT1,DISP=SHR
//SYSUT2   DD  DSN=&DSNUT2,DISP=(MOD,KEEP,KEEP)

The following shows the spooled output (or SYSOUT) of the expansion of the variable prior to the job being submitted for execution.

 135 //SYSUT1   DD  DSN=&DSNUT1,DISP=SHR
     SUBSTITUTION - DSN=SIMOTIME.DATA.SUB998D1,DISP=SHR
 136 //SYSUT2   DD  DSN=&DSNUT2,
     SUBSTITUTION - DSN=SIMOTIME.DATA.SUB100D1,

A Sample Job using JCL
(Next) (Previous) (Table-of-Contents)

The primary purpose of this sample job is to show the use of a single procedure (or PROC) to handle different files based on the variables passed from the JCL member that executes the PROC.

A Sample JCL Member
(Next) (Previous) (Table-of-Contents)

This is an eight (8) step job. The first job step (MAKENEAT) does the housekeeping and removes files that may be left from a previous execution of the job. Steps 2-5 make (or create) the primary files and the secondary files. Steps 6-8 will demonstrate the actual use of the variables and the use of IEBGENER for appending one file to another.

//JCLSUBJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2010 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Demonstrate parameter substitution.
//* Author - SimoTime Enterprises
//* Date   - January 24, 1996
//*
//* Step 1, MAKENEAT will delete any previously created files.
//* Step 2, MKSUB100 will create a new Base File (SUB100D1).
//* Step 3, MKSUB200 will create a new Base File (SUB200D1).
//* Step 4, MKSUB998 will create a new Base File (SUB998D1).
//* Step 5, MKSUB999 will create a new Base File (SUB999D1).
//* Step 6, AP998001 will add a 998 record to the base file (SUB100D1).
//* Step 7, AP999001 will add a 999 record to the base file (SUB100D1).
//* Step 8, AP999002 will add a 999 record to the base file (SUB200D1).
//*
//* This set of programs will run on a mainframe under MVS or on a
//* Personal Computer with Windows and Micro Focus Mainframe Express.
//*
//* 1. Demonstrate how to use IEFBR14 with DD statements to delete
//*    files that have been created by a previous execution of this
//*    job.
//* 2. Demonstrate how to use IEBGENER to create and populate a new
//*    record sequential file with eighty (80) byte fixed length
//*    records.
//* 3. Demonstrate how to use the SET and &variablename to use
//*    a single (common or shared) PROC to process different files.
//*
//* *******************************************************************
//* Step   1 of 8, Delete any previously created file...
//*
//MAKENEAT EXEC PGM=IEFBR14
//SUB100D1 DD  DSN=SIMOTIME.DATA.SUB100D1,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SUB200D1 DD  DSN=SIMOTIME.DATA.SUB200D1,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SUB998D1 DD  DSN=SIMOTIME.DATA.SUB998D1,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SUB999D1 DD  DSN=SIMOTIME.DATA.SUB999D1,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step   2 of 8, Create and populate a new QSAM file (SUB100D1).
//*                This will be a primary file that will have a
//*                secondary files appended in later job steps.
//*
//MKSUB100 EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DUMMY
//* :....1....:....2....:....3....:....4....:....5....:....6....:....7.
//SYSUT1   DD  *
001 Record 101
002 Record 102
003 Record 103
/*
//SYSUT2   DD  DSN=SIMOTIME.DATA.SUB100D1,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step   3 of 8, Create and populate a new QSAM file (SUB200D1).
//*                This will be a primary file that will have a
//*                secondary file appended in a later job step.
//*
//MKSUB200 EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DUMMY
//* :....1....:....2....:....3....:....4....:....5....:....6....:....7.
//SYSUT1   DD  *
001 Record 201
002 Record 202
003 Record 203
/*
//SYSUT2   DD  DSN=SIMOTIME.DATA.SUB200D1,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step   4 of 8, Create and populate a new QSAM file (SUB998D1).
//*                This is a secondary file that is used to append
//*                records to a primary file.
//*
//MKSUB998 EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DUMMY
//* :....1....:....2....:....3....:....4....:....5....:....6....:....7.
//SYSUT1   DD  *
998 Record 998
/*
//SYSUT2   DD  DSN=SIMOTIME.DATA.SUB998D1,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//*
//* *******************************************************************
//* Step   5 of 8, Create and populate a new QSAM file (SUB999D1)...
//*                This is a secondary file that is used to append
//*                records to a primary file.
//*
//MKSUB999 EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DUMMY
//* :....1....:....2....:....3....:....4....:....5....:....6....:....7.
//SYSUT1   DD  *
999 Record 999
/*
//SYSUT2   DD  DSN=SIMOTIME.DATA.SUB999D1,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step   6 of 8, Append the content of SYSUT2 to SYSUT1 within
//*                a Job Step using the SET statement to define a
//*                variable. Use the variable by referencing with
//*                the name preceded by an ampersand.
//*
//         SET DSNUT1=SIMOTIME.DATA.SUB998D1
//         SET DSNUT2=SIMOTIME.DATA.SUB100D1
//AP998001 EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DUMMY
//SYSUT1   DD  DSN=&DSNUT1,DISP=SHR
//SYSUT2   DD  DSN=&DSNUT2,
//             DISP=(MOD,KEEP,KEEP)
//*
//* *******************************************************************
//* Step   7 of 8, Append the content of SYSUT2 to SYSUT1 by setting a
//*                variable value within a Job Step using the SET
//*                statement to define a variable.
//*                Execute a procedure (or PROC). From within the PROC
//*                use the variable by referencing with
//*                the name preceded by an ampersand.
//*
//         SET DSNUT1=SIMOTIME.DATA.SUB999D1
//         SET DSNUT2=SIMOTIME.DATA.SUB100D1
//AP999001 EXEC JCLSUBP1
//SYSOUT   DD  SYSOUT=*
//*
//*
//* *******************************************************************
//* Step   8 of 8, Append the content of SYSUT2 to SYSUT1 by setting a
//*                variable value within a Job Step using the SET
//*                statement to define a variable.
//*                Execute a procedure (or PROC). From within the PROC
//*                use the variable by referencing with
//*                the name preceded by an ampersand.
//*        Note:   This step performs the same function and executes
//*                the same PROC as the preceding step.
//*                However, since the SET statements define a different
//*                value to the variables (DSNUT1 znd DSNUT2) the PROC
//*                will append a different file to a different primary
//*                file.
//*
//         SET DSNUT1=SIMOTIME.DATA.SUB999D1
//         SET DSNUT2=SIMOTIME.DATA.SUB200D1
//AP999002 EXEC JCLSUBP1
//SYSOUT   DD  SYSOUT=*
//*

A Sample JCL Procedure
(Next) (Previous) (Table-of-Contents)

This procedure is executed multiple times by the primary JCL member. The primary JCL member must set the two (2) variables name DSNUT1 and DSNUT2. The following procedure will append the file named by DSNUT2 to the end of the file named by SYSUT1.

//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2010 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Subject: Use IEBGENER to append SYSUT2 to the end of SYSUT1
//* Author:  SimoTime Enterprises
//* Date:    January 1,1998
//*
//* This PROC needs &DSNUT1 and DSNUT2 defined by the JCL member
//* that is executing this procedure.
//*
//* //       SET DSNUT1=AAAA.BBBB.CCCC
//* //       SET DSNUT2=AAAA.BBBB.DDDD
//* //       EXEC JCLSUBC1
//*
//*********************************************************************
//JCLSUBP1 PROC
//PRCSUBS1 EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DUMMY
//* :....1....:....2....:....3....:....4....:....5....:....6....:....7.
//SYSUT1   DD  DSN=&DSNUT1,DISP=SHR
//SYSUT2   DD  DSN=&DSNUT2,DISP=(MOD,KEEP,KEEP)
//*
//         PEND
//*

Summary
(Next) (Previous) (Table-of-Contents)

The purpose of this suite of programs is to describe how to define and use a variable within a JCL member or Procedure member.

Software Agreement and Disclaimer
(Next) (Previous) (Table-of-Contents)

Permission to use, copy, modify and distribute this software for any non-commercial purpose and without fee is hereby granted, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software.

SimoTime Enterprises makes no warranty or representations about the suitability of the software for any purpose. It is provided "AS IS" without any express or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Enterprises shall not be liable for any direct, indirect, special or consequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software.

Downloads and Links to Similar Pages of Interest
(Next) (Previous) (Table-of-Contents)

You may download an evaluation copy of this example at  http://www.simotime.com/sim4dzip.htm#ZipTagjclsub01  or view the complete list of SimoTime Examples at  http://www.simotime.com/sim4dzip.htm .

Note: You must be attached to the Internet to download a Z-Pack or view the list.

Check out  JCL Substitution and Procedural Overrides  and  Using JCL Procedures  for additional examples.

Check out   The JCL Connection  for more mainframe JCL examples.

To review all the information available on this site start at  The SimoTime Home Page .

Glossary of Terms
(Next) (Previous) (Table-of-Contents)

Check out  The SimoTime Glossary  for a list of terms and definitions used in the documents provided by SimoTime.

Comments or Suggestions
(Next) (Previous) (Table-of-Contents)

If you have any questions, suggestions or comments please call or send an e-mail to: helpdesk@simotime.com

About SimoTime Enterprises
(Next) (Previous) (Table-of-Contents)

Founded in 1987, SimoTime Enterprises is a privately owned company. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. This includes the smallest thin client using the Internet and the very large mainframe systems. There is more to making the Internet work for your company's business than just having a nice looking WEB site. It is about combining the latest technologies and existing technologies with practical business experience. It's about the business of doing business and looking good in the process. Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems. Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com


Return-to-Top
Copyright © 1987-2010 SimoTime Enterprises  All Rights Reserved
When technology complements business
http://www.simotime.com
Version 07.07.10