Pass JCL symbol to in-stream data sets
Asked Answered
N

2

5

I'm trying to create and delete a dataset with a JCL symbol in the dataset name this way:

//    SET DATE=20110809
//* DELETE DATASET
//DEL01 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN    DD *
           DELETE DATASET.TEMP.&DATE                PURGE
           SET MAXCC = 0
//* CREATE DATASET
//STEP01   EXEC PGM=IEFBR14
//DELDD    DD DSN=DATASET.TEMP.&DATE,
//            DISP=(NEW,CATLG,DELETE)

The problem is that I can not use a JCL symbol within a instream (SYSIN DD *). I can't be sure if the dataset already exists so I can not just use DISP=(MOD,DELETE,DELETE). Is there another way to delete the data set?

Nachison answered 9/8, 2011 at 15:41 Comment(0)
A
8

JCL does not support symbol substitution within inline data as you have found out...

The following should work for you:

//DEL01   EXEC PGM=IEFBR14          
//DELDD    DD DSN=DATASET.TEMP.&DATE, 
//         DISP=(MOD,DELETE,DELETE), 
//         SPACE=(TRK,0)             

Add a SPACE parameter. If the dataset doesn't exist it will be created because of the MOD disposition. Then it will be DELETED upon step completion. Net result is that after this step, the named dataset will not exist.

The only real problem that I see is with:

//    SET DATE=20110809

The date you are giving is 8 characters long (maximum qualifier length) but does not begin with an alphabetic or national character (it begins with a numeric). This will result in an invalid dataset name. The dataset DATE qualifer will become too long if you just add an alpha prefix to it. The common approach to this problem is to use Julian dates as in: 2011221. Prefix the Julian Date with either an alpah or national character as in: D2011221. So your SET directive would become something like:

//    SET DATE=D2011221

And all should work out.

Anamorphism answered 9/8, 2011 at 17:44 Comment(4)
Thanks! It doesn't really pass JCL symbols to instream but it really suits my needs :)Nachison
Cant we use DISP=OLD? I have never used this with IEFBR14 but guessing whether it works. And... If we want to refer the datasets created already referring to date, this Julian date is a bit confusing i suppose. We can make use the actual date only by using YYMMDD format, right. Just a suggestion!Sleight
@Raja Reddy. No you should not use DISP=OLD here. If the dataset does not yet exist the step will fail (dataset not found). DISP=MOD will create the dataset if it does not yet exist - just so it can then delete it! Seems stupid - but that is the way it works. On the other hand, if the dataset already exists, DISP=MOD will use the existing dataset - and then delete it. Net result is the dataset will not exist after the step completes.Anamorphism
Ofcos Neal, I presumed that it should exist in order to delete. But giving DISP=MOD would be proactive usage.Sleight
C
9

As of z/OS 2.1 (released 30 September 2013), using symbols in JES2 in-stream data is possible by adding the SYMBOLS keyword to the DD statement. Possible values are:

  • SYMBOLS=JCLONLY: Replaces JCL symbols and JES symbols in the in-stream data.

  • SYMBOLS=EXECSYS: Replaces JCL symbols, JES symbols, and system symbols defined on the system during job execution.

  • SYMBOLS=CNVTSYS: Replaces JCL symbols, JES symbols, and system symbols defined on the system during JCL conversion.

The symbols must have been exported.

An example is as follows, from [2]:

// EXPORT SYMLIST=(DSN,VOL)
// SET DSN='ABC.DATA',VOL='123456'
//STEP1 EXEC PGM=USERPGM1
//DATA     DD DSN=&DSN,DISP=SHR
//SYSIN    DD *,SYMBOLS=EXECSYS
  SYSTEM=&SYSNAME,DSNAME=&DSN,VOLUME=&VOL
  FUNCTION='&APPL_NAME'
/*

For more information, including the syntax for configuring where the symbol substitution log goes, see:

Chiro answered 11/10, 2013 at 13:30 Comment(1)
Great development on the z/OS, thanks for the input.Nachison
A
8

JCL does not support symbol substitution within inline data as you have found out...

The following should work for you:

//DEL01   EXEC PGM=IEFBR14          
//DELDD    DD DSN=DATASET.TEMP.&DATE, 
//         DISP=(MOD,DELETE,DELETE), 
//         SPACE=(TRK,0)             

Add a SPACE parameter. If the dataset doesn't exist it will be created because of the MOD disposition. Then it will be DELETED upon step completion. Net result is that after this step, the named dataset will not exist.

The only real problem that I see is with:

//    SET DATE=20110809

The date you are giving is 8 characters long (maximum qualifier length) but does not begin with an alphabetic or national character (it begins with a numeric). This will result in an invalid dataset name. The dataset DATE qualifer will become too long if you just add an alpha prefix to it. The common approach to this problem is to use Julian dates as in: 2011221. Prefix the Julian Date with either an alpah or national character as in: D2011221. So your SET directive would become something like:

//    SET DATE=D2011221

And all should work out.

Anamorphism answered 9/8, 2011 at 17:44 Comment(4)
Thanks! It doesn't really pass JCL symbols to instream but it really suits my needs :)Nachison
Cant we use DISP=OLD? I have never used this with IEFBR14 but guessing whether it works. And... If we want to refer the datasets created already referring to date, this Julian date is a bit confusing i suppose. We can make use the actual date only by using YYMMDD format, right. Just a suggestion!Sleight
@Raja Reddy. No you should not use DISP=OLD here. If the dataset does not yet exist the step will fail (dataset not found). DISP=MOD will create the dataset if it does not yet exist - just so it can then delete it! Seems stupid - but that is the way it works. On the other hand, if the dataset already exists, DISP=MOD will use the existing dataset - and then delete it. Net result is the dataset will not exist after the step completes.Anamorphism
Ofcos Neal, I presumed that it should exist in order to delete. But giving DISP=MOD would be proactive usage.Sleight

© 2022 - 2024 — McMap. All rights reserved.