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
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1079

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 COBOL Table data to a flat file with ... COBOL Programming 5
No new posts Compare 2 files replace data in 1st f... DFSORT/ICETOOL 4
No new posts DB2 SQL query to read and update data... DB2 12
This topic is locked: you cannot edit posts or make replies. copy file 2 data into file1 for match... DFSORT/ICETOOL 4
No new posts DATA SET LIST UTILITY screen TSO/ISPF 6
Search our Forums:

Back to Top