So to help me understand your term Nested Proc I think of a nested proc as a proc calling a proc.
When you have an individual proc executed multiple times, I do not consider that nested. Next, I agree with @Charles. Move the EXPORT and SET statements outside of the proc. Note: When using Nested Procs - PROCA executes PROCB executes PROCC. The symbols are not available at the lower level procs (PROCB and PROCC in this example). So any changes will need to be done within PROCB and PROCC. It is better to invoke procs on a single level so symbols and symbolics are easy to set. Lizette > -----Original Message----- > From: IBM Mainframe Discussion List [mailto:[email protected]] On > Behalf Of Andrew Rowley > Sent: Tuesday, April 25, 2017 10:14 PM > To: [email protected] > Subject: Adventures in JCL: PROCs, symbols and instream data > > I am trying to create some JCL procedures using symbols in instream data, with > the ability to override the symbol using standard procedure calling > conventions. > > This almost works: > > //JOB1 JOB CLASS=A, > // MSGCLASS=H, > // NOTIFY=&SYSUID > //* > //TEST PROC MESSAGE='''Hello World''' > //SYMBOLS EXPORT SYMLIST=(SYM) > // SET SYM=&MESSAGE > //S1 EXEC PGM=IEBGENER > //SYSIN DD DUMMY > //SYSPRINT DD DUMMY > //SYSUT1 DD *,SYMBOLS=JCLONLY > &SYM > //SYSUT2 DD SYSOUT=* > // PEND > //* > //S1 EXEC TEST > //S2 EXEC TEST,MESSAGE='''Hello Again''' > //*S3 EXEC TEST > > Output is > > Hello World > Hello Again > > but if you uncomment S3 the output is: > > Hello World > Hello World > Hello World > > I think the problem is the placement of the EXPORT statement - the proc can't > EXPORT the parameters used to call it. I used the SET statement to get around > that but it has side effects. > > I can get it to work (I think) with nested procedures: > > //JOB2 JOB CLASS=A, > // MSGCLASS=H, > // NOTIFY=&SYSUID > //* > //TEST PROC MESSAGE='''Hello World''' > //SYMBOLS EXPORT SYMLIST=(MESSAGE) > //INNER EXEC INNER,MESSAGE=&MESSAGE > // PEND > //* > //INNER PROC > //S1 EXEC PGM=IEBGENER > //SYSIN DD DUMMY > //SYSPRINT DD DUMMY > //SYSUT1 DD *,SYMBOLS=JCLONLY > &MESSAGE > //SYSUT2 DD SYSOUT=* > // PEND > //* > //S1 EXEC TEST > //S2 EXEC TEST,MESSAGE='''Hello Again''' > //S3 EXEC TEST > > Output is as expected: > > Hello World > Hello Again > Hello World > > but nested PROCs is getting a bit clunky. I suspect it would work if the > caller exported the symbols before calling the proc, but the idea of procs is > to hide that sort of detail. > > Does anyone know of a neater way to do this (using JCL only)? Is there any way > to avoid the need for the triple apostrophes? > > I'm also interested to know if I am breaking any JCL rules that might be > tightened up later. > > -- > Andrew Rowley > Black Hill Software > +61 3 5331 8201 ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
