Page 1 of 1

Variable part in a JCL variable name

PostPosted: Wed Jun 16, 2021 3:01 pm
by RalphEagle
Hi,

I am defining variable names inside a JCL, such as:
//V1   SET SELO='WORK.JOHN.SHEET'
//V2   SET SELRFMT='WORK.JOHN.OUTPUT.CODE'


I would like to introduce a variable part in these, so that the name JOHN above can be customized as well:
//V0   SET NAME='MARY'
//V1   SET SELO='WORK.&NAME..SHEET'
//V2   SET SELRFMT='WORK.&NAME..OUTPUT.CODE'


I get an error from improper use of ampersand in the DSN field, I suppose because double substitution is not recognized?
6 IEFC627I INCORRECT USE OF AMPERSAND IN THE DSN FIELD


Is there a way to do this?

Thank you,

Re: Variable part in a JCL variable name

PostPosted: Wed Jun 16, 2021 5:08 pm
by sergeyken
Do not use quotes when combining new value including other SET-variables.
This way you’ll be on safe side.
//V0   SET NAME='MARY'
//V1   SET SELO=WORK.&NAME..SHEET
//V2   SET SELRFMT=WORK.&NAME..OUTPUT.CODE

Re: Variable part in a JCL variable name

PostPosted: Wed Jun 16, 2021 5:34 pm
by willy jensen
Actually, don't use quotes unless absolutely necessary
//V0   SET NAME=MARY                        
//V1   SET SELO=WORK.&NAME..SHEET          
//V2   SET SELRFMT=WORK.&NAME..OUTPUT.CODE

Re: Variable part in a JCL variable name

PostPosted: Wed Jun 16, 2021 5:49 pm
by RalphEagle
Thanks, it worked like a charm!

Re: Variable part in a JCL variable name

PostPosted: Wed Jun 16, 2021 6:05 pm
by sergeyken
The problem with quotes, and parameters has been created by IBM itself, long time ago.

Parameters are substituted within quotes in PARM field:
// EXEC PGM=xxxx,PARM=‘&START,&END’ - this works fine


The same parameters are NOT substituted in most of other situations with quotes:
// SET ALLPARM=‘&START,&END’     - ampersands are not resolved
// EXEC PGM=xxxx,PARM=‘&ALLPARM’ - this does not work
// EXEC PGM=yyyy,PARM=&ALLPARM   - this does not work as well


We need to blame IBM for this mess they have created!

Re: Variable part in a JCL variable name

PostPosted: Wed Jun 16, 2021 6:23 pm
by sergeyken
But there is one secret trick
// SET QUOTE=’’’’
// SET COMMA=’,’
// SET ALLPARM=&QUOTE&START&COMMA&END&QUOTE
// EXEC PGM=yyyy,PARM=&ALLPARM   - this works! But is ugly…