Move the EXPORT outside of the PROC and into the open JOB?

Charles


-----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?

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

Reply via email to