IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

JCL (SET) variables in input stream data


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2011
Location: USA

PostPosted: Wed Apr 07, 2021 6:56 pm
Reply with quote

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 icon_biggrin.gif

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]
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
No new posts JCL EXEC PARM data in C Java & MQSeries 2
Search our Forums:

Back to Top