Discussion:
Using system symbols in JCL IF statement
(too old to reply)
Gadi Ben-Avi
2018-05-14 08:46:32 UTC
Permalink
Hi,
Is it possible to use system symbols in a JCL IF statement?

So, for example, if I have a smbold called DR whos value is DR, I would like to write:

// IF &DR=DR THEN
Do stuff for a DR system
// ELSE
Do stuf for the production system
// ENDIF

I am running z/OS v2.1

Thanks

Gadi

????? ?? ????? ???? ???? ???? ?????? ??? ??? ?????? ???? ????? ??? ?????? ??????. ?? ????, ???????? ?? ??? ???? ?????, ??????? ???? ???? ????? ?? ??? ????? ?????? ?? ?????. ????? ????? ???? ?? ?????? ?????? ?????? ???? ?? ???? ??????? ??? ???, ?/?? ?????, ????? ?? ????? ????? ????? ????? ?????? ?? ????? ??????? ?/?? ?????? ?? ??????.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Binyamin Dissen
2018-05-14 10:55:20 UTC
Permalink
IF does not support string comparisons.

What you can do is add a step that generates a return code based on the symbol
value and use that return code in an IF statement.

On Mon, 14 May 2018 08:48:29 +0000 Gadi Ben-Avi <***@MALAM.COM> wrote:

:>Is it possible to use system symbols in a JCL IF statement?

:>So, for example, if I have a smbold called DR whos value is DR, I would like to write:

:>// IF &DR=DR THEN
:> Do stuff for a DR system
:>// ELSE
:> Do stuf for the production system
:>// ENDIF

:>I am running z/OS v2.1

--
Binyamin Dissen <***@dissensoftware.com>
http://www.dissensoftware.com

Director, Dissen Software, Bar & Grill - Israel


Should you use the mailblocks package and expect a response from me,
you should preauthorize the dissensoftware.com domain.

I very rarely bother responding to challenge/response systems,
especially those from irresponsible companies.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Charles Mills
2018-05-14 13:09:03 UTC
Permalink
Here FWIW is a fragment of a working example:

//* Need to set a return code so we know whether to do the ASM and
//* OBJ copies, which we only want to do if new code base (&CSOURCE)
//* Sets RC=0 if equal, RC=8 otherwise
//COMPSRC EXEC PGM=IEBCOMPR
//SYSIN DD DUMMY
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD *,SYMBOLS=JCLONLY
&PREVSRC
/*
//SYSUT2 DD *,SYMBOLS=JCLONLY
&CSOURCE
/*

//* Create the LST PDSE only if new ASM version
//MAKELST EXEC PGM=IEFBR14,COND=(0,EQ,COMPSRC) Bypass if compare =
//DDLST DD DSN=xxxxxx.&CSOURCE..LST,
// DCB=(xxxxxx.&PREVSRC..LST),
// DISP=(NEW,CATLG),SPACE=(CYL,(15,5,20)),DSNTYPE=LIBRARY

//* Create the load PDSE only if new code base or package
// IF (COMPSRC.RC NE 0 | COMPCZA.RC NE 0 ) THEN
//MKRLOAD EXEC PGM=IEFBR14
//DDLOAD DD DSN=&LOADLIB,
// DCB=(xxxxxx.&PREVSRC..&PREVPKG..LOADPDSE),
// DISP=(NEW,CATLG),SPACE=(TRK,(75,15,20)),DSNTYPE=LIBRARY
// ENDIF

Charles

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-***@LISTSERV.UA.EDU] On
Behalf Of Binyamin Dissen
Sent: Monday, May 14, 2018 3:57 AM
To: IBM-***@LISTSERV.UA.EDU
Subject: Re: Using system symbols in JCL IF statement

IF does not support string comparisons.

What you can do is add a step that generates a return code based on the
symbol
value and use that return code in an IF statement.

On Mon, 14 May 2018 08:48:29 +0000 Gadi Ben-Avi <***@MALAM.COM> wrote:

:>Is it possible to use system symbols in a JCL IF statement?

:>So, for example, if I have a smbold called DR whos value is DR, I would
like to write:

:>// IF &DR=DR THEN
:> Do stuff for a DR system
:>// ELSE
:> Do stuf for the production system
:>// ENDIF

:>I am running z/OS v2.1

--
Binyamin Dissen <***@dissensoftware.com>
http://www.dissensoftware.com

Director, Dissen Software, Bar & Grill - Israel


Should you use the mailblocks package and expect a response from me,
you should preauthorize the dissensoftware.com domain.

I very rarely bother responding to challenge/response systems,
especially those from irresponsible companies.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Jantje.
2018-05-15 11:51:24 UTC
Permalink
Post by Binyamin Dissen
IF does not support string comparisons.
What you can do is add a step that generates a return code based on the symbol
value and use that return code in an IF statement.
Or just use a numeric value in your symbol…


Jantje.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Paul Gilmartin
2018-05-15 13:36:11 UTC
Permalink
Post by Jantje.
Post by Binyamin Dissen
IF does not support string comparisons.
What you can do is add a step that generates a return code based on the symbol
value and use that return code in an IF statement.
Or just use a numeric value in your symbol…
I believe the only comparisons supported by IF are to a result, such as a return
code, of a previous step.

But you can use symbol substitution in SYSIN to control the return code of
a utility such as IDCAMS.

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Jantje.
2018-05-16 10:42:15 UTC
Permalink
Post by Paul Gilmartin
I believe the only comparisons supported by IF are to a result, such as a return
code, of a previous step.
All examples given do indeed lead one to believe that, but the actual documentation does not specify such a requirement. It does say that the parts to be compared in the expression must be numeric.


https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.1.0/com.ibm.zos.v2r1.ieab600/relationexp.htm says:
<quote>
A relational-expression consists of:
Comparison operators
Logical operators
NOT (¬) operators
Relational-expression keywords
Numeric values
</quote>


I did the test, comparing a symbol (that has a numeric value assigned to it) to a constant numeric value and it works just fine. No RC in my test.


Cheers,

Jantje.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Paul Gilmartin
2018-05-16 13:36:27 UTC
Permalink
Post by Jantje.
Post by Paul Gilmartin
I believe the only comparisons supported by IF are to a result, such as a return
code, of a previous step.
All examples given do indeed lead one to believe that, but the actual documentation does not specify such a requirement. It does say that the parts to be compared in the expression must be numeric.
I don't see where you find "must be numeric" although it makes sense. Can you
supply more context?
Post by Jantje.
<quote>
Comparison operators
Logical operators
NOT (¬) operators
Relational-expression keywords
Numeric values
</quote>
I did the test, comparing a symbol (that has a numeric value assigned to it) to a constant numeric value and it works just fine. No RC in my test.
In: z/OS IBM MVS JCL Reference Version 2 Release 3 SA23-1385-30
Chapter 18. IF/THEN/ELSE/ENDIF statement construct
Description
Relational-expression field
Comparison operators
Use comparison operators in a relational-expression to
compare a keyword with a numeric value. The comparison
results in a true or false condition.

... does not say a numeric value may be compared to another numeric
value. (But it doesn't explicitly prohibit it.) I'll submit an RCF. It also
doesn't specify the order of the operands. Are "4 = RC" and "RC = 4"
both valid?

Relational-expression keywords
The following keywords are the only keywords supported by
IBM and recommended for use in relational-expressions.
Any other keywords, even if accepted by the system, are
not intended or supported keywords.

... lists several keywords. "numeric value" is not listed as a keyword.
The "even if accepted" clause is a cowardly excuse for not supplying
proper warnings on use of unsupported constructs. But Peter Relson has
said that such constructs are reserved for present or future use within
IBM. I can't respect that.

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Loading...