sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2011 Location: USA
|
|
|
|
Since long time IBM has implemented usage of their JCL variables (and system variables as well) not only to substitute the values as parts of JCL statements, but also as part of input data stream (e.g. of the stuff going under DD *). One extra JCL statement
// EXPORT SYMLIST=...
and one extra DD parameter
SYMBOLS=(…,[ddname])
have been added to JCL syntax in order to support this feature. It really made out life easier
Unfortunately there is a small difference which may cause big problems:
1) JCL variables are substituted into JCL statements during initial JCL parsing, along with resolving JCL procedures, etc.
2) The same JCL variables are substituted into input data stream only at the moment the running program tries to open its DD * input data.
The problem is, the same JCL variable may change its value by the moment the job step execution begins, compared to the moment the same variable was substituted into the JCL statements of the same job step.
This is an example to clarify and to demonstrate this issue (with some comments); the JCL can be analyzed and/or executed.
Code: |
//*====================================================================
//* Stream Variables Test
//*
//* This JCL is to demonstrate specifics of substitution
//* of set-variables
//*====================================================================
//*
// EXPORT SYMLIST=* allow any of SET variables to be in input steam(s)
//*
//*====================================================================
//* ATTEMPT #1
//*====================================================================
// SET X=1
// SET Y=1
// SET Z=1
//*
//TRY1 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*,COPIES=&Y, value Y=1
// SPACE=(TRK,(&X,&X),RLSE) value X=1
//SYSIN DD DUMMY
//LISTUT1 DD SYSOUT=* log of in-stream substitution
//SYSUT1 DD *,SYMBOLS=(EXECSYS,LISTUT1)
X=&X value X=1
Y=&Y value Y=2
Z=&Z value Z=3
//*
// SET Y=2
//SYSUT2 DD SYSOUT=*,COPIES=&Y, value Y=2
// SPACE=(TRK,(&Z,&Z),RLSE) value Z=1
//*
//*====================================================================
//* ATTEMPT #2
//*====================================================================
// SET Z=3
//*
//TRY2 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*,COPIES=&Y, value Y=2
// SPACE=(TRK,(&X,&X),RLSE) value X=1
//SYSIN DD DUMMY
//LISTUT1 DD SYSOUT=* log of in-stream substitution
//SYSUT1 DD *,SYMBOLS=(EXECSYS,LISTUT1)
X=&X value X=1
Y=&Y value Y=4
Z=&Z value Z=3
//*
// SET Y=4
//SYSUT2 DD SYSOUT=*,COPIES=&Y, value Y=4
// SPACE=(TRK,(&Z,&Z),RLSE) value Z=3
//*==================================================================== |
I hope this may be useful; I've got periodically very unexpected results before figured out the reason of this problem.[/list] |
|