This code works:

//         SET Z=''
//         SET CPPOBJ='/u/userid/CertRept/Obj/'
//         SET SHELL1B=&Z'cd &CPPOBJ'
//JS010   EXEC PGM=IEFBR14,PARM='&SHELL1B'

Reason is documented in the JCL Reference manual under Procedures and Symbols > 
Using system symbols and JCL symbols > Determining equivalent JCL > Coding 
symbols in apostrophes

https://www.ibm.com/docs/en/zos/2.5.0?topic=jcl-coding-symbols-in-apostrophes

Basically:

- The system DOES pick up previous SET symbols on subsequent SET commands
- Yours didn't work because your CPPOBJ value is enclosed in apostrophes
- The system normally only resolves symbols in apostrophes when used in AMP, 
PATH, SUBSYS, ACCT, or PARM parameters (DD and EXEC statements). Notice that 
SET isn't in the list, hence your problem.

But, guess what I learned today? "On parameters that are not in the list, the 
system correctly resolves a symbol that is enclosed in apostrophes when the 
symbol is immediately preceded by a symbol that is not enclosed in apostrophes. 
"

So by adding the &Z symbol before the apostrophe string, the symbols in the 
apostrophes do get resolved. I set the &Z string to null.

-----Original Message-----
From: IBM Mainframe Discussion List <[email protected]> On Behalf Of 
Charles Mills
Sent: Friday, October 24, 2025 12:39 PM
To: [email protected]
Subject: How use a set symbol in a SET statement?

I have JCL that includes the following sequence

 //    SET CPPOBJ='/u/userid/CertRept/Obj/'
...
// SET SHELL1B='cd &CPPOBJ'
...
//BPXARCH  EXEC PGM=BPXBATCH,COND=(4,LT),
// PARM='SH&B&SHELL1B;...

The BPXBATCH cd fails because &SHELL1B has the literal value cd &CPPOBJ -- in 
other words, the path name was not substituted for the symbol name &CPPOBJ.

Is there any way to set a symbol to a string that includes the value of a SET 
symbol?

If not, yeah, I can think of several possible workarounds but this seems like a 
pretty gigantic shortcoming to me. The exclamation "Really?" comes to mind.

I see an IBM-MAIN post by the sorely missed @Peter Relson from Dec 4, 2021, at 
10:05 AM with a subject of "Re: Trying to use long parm= in started task" that 
addresses this issue but I don't see a resolution. Is there one?

Charles

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN



----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to