MainframeMaster
Thread: JCL and JCL Utilities

JCL double substitution and conditional substitution

Started by gregorytwin • user1 replies1 viewsLast activity 7 minutes ago
Post #1
0 votes
gregorytwin
Reputation
0
Posts: 1
Joined: Sep 21, 2026, 6:06 PM
Posted: Sep 21, 2026, 6:22 PM

Hello All.
Occasionally find this article [https://www.mainframemaster.com/tutorials/jcl/quick-reference/symbolic-substitution-delimiters]
I suppose, an example

``
//STEP1 EXEC PGM=MYPGM
// SET PREFIX=PROD
// SET SUFFIX=DATA
//INPUT DD DSN=&PREFIX..&SUFFIX,
// DISP=SHR
//*
// IF (STEP1.RC = 0) THEN
// SET STATUS=SUCCESS
// ELSE
// SET STATUS=FAILURE
// ENDIF
//*
//STEP2 EXEC PGM=REPORTER,PARM='&STATUS'


would never works as expected: &STATUS value would be always FAILURE. IBM z/OS 3.1 SA23-1385-60 MVS JCL Reference page 38 clearly state:

If you define duplicate JCL symbols on a SET statement, the system assigns the last substitution text
to the JCL symbol.
Note: The substitution text specified on the SET statement is assigned to the JCL symbol regardless of
the logic of the construct. This is because the SET statement is not executed conditionally (such as in
the THEN and ELSE clauses of an IF/THEN/ELSE/ENDIF statement construct)


Furthermore, the next example

//STEP1 EXEC PGM=MYPGM
// SET ENV=PROD
// SET PRODDSN=PRODUCTION.MASTER
// SET TESTDSN=TEST.MASTER
//INPUT DD DSN=&&&ENV.DSN,
// DISP=SHR

is completely wrong. Double substitution in JCL impossible, because JES2 perform job conversion in single scan. So, DSN would be &&PRODDSN rather than PRODUCTION.MASTER.DSN.
Did you ever try check these example? I did, on z/OS 2.5 (as you state) and z/OS 3.1. Of course, both example failed...

Regards,
Gregory

You must be signed in to reply to this thread