Variable part in a JCL variable name

JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...
RalphEagle
Posts: 24
Joined: Mon Apr 23, 2018 2:51 pm
Skillset: Cobol, CICS, DB2
Referer: regular google searches

Variable part in a JCL variable name

Postby RalphEagle » Wed Jun 16, 2021 3:01 pm

Hi,

I am defining variable names inside a JCL, such as:

Code: Select all

//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:

Code: Select all

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

Code: Select all

6 IEFC627I INCORRECT USE OF AMPERSAND IN THE DSN FIELD


Is there a way to do this?

Thank you,

User avatar
sergeyken
Posts: 458
Joined: Wed Jul 24, 2019 10:12 pm
Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
Referer: Internet search

Re: Variable part in a JCL variable name

Postby sergeyken » Wed Jun 16, 2021 5:08 pm

Do not use quotes when combining new value including other SET-variables.
This way you’ll be on safe side.

Code: Select all

//V0   SET NAME='MARY'
//V1   SET SELO=WORK.&NAME..SHEET
//V2   SET SELRFMT=WORK.&NAME..OUTPUT.CODE
Javas and Pythons come and go, but JCL and SORT stay forever.

willy jensen
Posts: 474
Joined: Thu Mar 10, 2016 5:03 pm
Skillset: assembler rexx zOS ispf racf smf
Referer: saw it in the experts foprum thought I could help here

Re: Variable part in a JCL variable name

Postby willy jensen » Wed Jun 16, 2021 5:34 pm

Actually, don't use quotes unless absolutely necessary

Code: Select all

//V0   SET NAME=MARY                        
//V1   SET SELO=WORK.&NAME..SHEET          
//V2   SET SELRFMT=WORK.&NAME..OUTPUT.CODE

RalphEagle
Posts: 24
Joined: Mon Apr 23, 2018 2:51 pm
Skillset: Cobol, CICS, DB2
Referer: regular google searches

Re: Variable part in a JCL variable name

Postby RalphEagle » Wed Jun 16, 2021 5:49 pm

Thanks, it worked like a charm!

User avatar
sergeyken
Posts: 458
Joined: Wed Jul 24, 2019 10:12 pm
Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
Referer: Internet search

Re: Variable part in a JCL variable name

Postby sergeyken » Wed Jun 16, 2021 6:05 pm

The problem with quotes, and parameters has been created by IBM itself, long time ago.

Parameters are substituted within quotes in PARM field:

Code: Select all

// EXEC PGM=xxxx,PARM=‘&START,&END’ - this works fine


The same parameters are NOT substituted in most of other situations with quotes:

Code: Select all

// 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!
Javas and Pythons come and go, but JCL and SORT stay forever.

User avatar
sergeyken
Posts: 458
Joined: Wed Jul 24, 2019 10:12 pm
Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
Referer: Internet search

Re: Variable part in a JCL variable name

Postby sergeyken » Wed Jun 16, 2021 6:23 pm

But there is one secret trick

Code: Select all

// SET QUOTE=’’’’
// SET COMMA=’,’
// SET ALLPARM=&QUOTE&START&COMMA&END&QUOTE
// EXEC PGM=yyyy,PARM=&ALLPARM   - this works! But is ugly…
Javas and Pythons come and go, but JCL and SORT stay forever.


  • Similar Topics
    Replies
    Views
    Last post