Page 1 of 2

SETVAR SUBSTR issue

PostPosted: Tue Mar 19, 2019 4:24 pm
by eastydl
Hi, I'm trying to run JCL where a 4 character variable &DLC is passed to it (along with others) but I just want to use the first 3 characters, I've tried to run the following creating a new variable SID with the first 3 characters of &DLC and then pass to the SEND step but it doesn't work, any help would be greatly appreciated, thanks

//*%OPC SCAN
//*%OPC SETVAR SID=SUBSTR(&DLC,1,3)
//*
//SEND EXEC PGM=DF080A00
//STEPLIB DD DSN=xxx.xxx.xxx,DISP=SHR
//SYSPRINT DD SYSOUT=*
//STATIONS DD DSN=xxx.xxx.xxx,DISP=SHR
//SYSIN DD *,SYMBOLS=JCLONLY
SID=&SID.,DSNOLD=&OFDSN.,
DSN=&VFN.
/*

Re: SETVAR SUBSTR issue

PostPosted: Tue Mar 19, 2019 8:51 pm
by willy jensen
Say 'it doesn't work' is not particular useful, what excactly happens?
Seems you are mixing OPC variables and JCL variables.
I would suggest removing the ',SYMBOLS=JCLONLY ' from the SYSIN DD and maybe test it with an IEBGENER step.

Re: SETVAR SUBSTR issue

PostPosted: Tue Mar 19, 2019 9:27 pm
by eastydl
The variable SID is not resolved, thanks.

Re: SETVAR SUBSTR issue

PostPosted: Tue Mar 19, 2019 10:31 pm
by willy jensen
Could you add another line :
SID=&DLC.,DSNOLD=&OFDSN.,
and verify that it expands correctly?
Please post the results.

Re: SETVAR SUBSTR issue

PostPosted: Tue Mar 19, 2019 10:49 pm
by eastydl
Thanks, I removed ,SYMBOLS=JCLONLY & run again & the output shows

SID=&SID.,DSNOLD=&OFDSN.,
DSN=SDARMAOW

ERROR: ERROR NEAR PARAMETER: SID
ACTION: ** REQUEST NOT ACCEPTED **

I guess DSNOLD doesn't resolve as SID fails but DSN does resolve ok

Re: SETVAR SUBSTR issue

PostPosted: Tue Mar 19, 2019 10:57 pm
by willy jensen
How about an IEBGENER like this?

//SEND     EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT2   DD SYSOUT=*
//SYSUT1   DD *
DLC=&DLC
SID=&SID
DSNOLD=&OFDSN
DSN=&VFN

Re: SETVAR SUBSTR issue

PostPosted: Tue Mar 19, 2019 11:16 pm
by eastydl
The job doesn't output anything
1DATA SET UTILITY - GENERATE
SYNCSORT COPY FEATURE CALLED - RC = 0
DLC=&DLC
SID=&SID
DSNOLD=&OFDSN
DSN=&VFN

Re: SETVAR SUBSTR issue

PostPosted: Tue Mar 19, 2019 11:53 pm
by willy jensen
Well, it did output something, it clearly showed that the OPC, sorry TWS, variables were not resolved.
You did keep the '//*%OPC ' statements, right?
As there is no JOB statement, I assume that you look at the generated JCL through TWS?

Re: SETVAR SUBSTR issue

PostPosted: Tue Mar 19, 2019 11:56 pm
by eastydl
Yep, kept the OPC statements in.

Re: SETVAR SUBSTR issue

PostPosted: Wed Mar 20, 2019 12:30 am
by willy jensen
So my earlier conclusion stays, none of the variables were resolved, thus not a problem with SUBSTR.
I'm no TWS expert, just used it from time to time, so I'm afraid that I can't help you.