Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Conditional expressions

&pagelevel(4)&pagelevel

A conditional expression is used to make processing of the ADD-CJC-ACTION, SKIP-COMMANDS or WAIT-EVENT command dependent on job variable values. A conditional expression may be either “true” or “false”. It is composed of one or more relational expressions <relation.exp> which can be constructed as follows. Alternatives are separated by “/”; optional entries are enclosed in angle brackets.

<relation.exp>      ::=  (<term> <comparison-op> <term>)
<term>              ::=  <jvid> / <jv-subarea-def> / <const>
<relational-op>     ::=  <  / >  / =  / <= / >= / <>
                         LT / GT / EQ / LE / GE / NE
<jvid>              ::=  <jvname> / <*jvlink> / <#jvname> / <special-jvname>
<jvname>            ::=  Name of a permanent user job variable
<*jvlink>           ::=  Link name of a user job variable with
                         leading asterisk (*)
<#jvname>           ::=  Name of a temporary user job variable
<special-jvname>    ::=  Name of a special job variable without catalog ID 
                         but with specification of user ID SYSJV (only 
                         permitted in the SKIP-COMMANDS command).
<jv-subarea-def>    ::=  (<jvid> [,[<start>][,<length>]])
<start>             ::=  <integer 1..256>  default=1
<length>            ::=  <integer 1..64>  default=64
                         (with <start>+<length> <= 256)
<const>             ::=  <c-string 1..64> / <x-string 1..128>
                         e.g.:
                           C'HALLO' / 'HALLO' or
                           X'00FF'  / X'0FF'

The operators LT, GT, EQ, LE, GE, NE must be separated from other letters by a blank (in constants, JV names or link names).
Particular attention should also be paid to differentiating between uppercase and lowercase notation in conditional expressions.

Compound conditional expressions are produced by combining relational expressions with the aid of logical operators:

<cond.exp>          ::= (<relation.exp> <logical.op> <relation.exp>) /
                        (<cond.exp> <logical.op> <cond.exp>) /
                        NOT <cond.exp>)

<logical.op>        ::=   AND        /     OR        /       XOR
                        logical AND     logical OR       exclusive OR

Example

(JV1=C'START')
((JV2=C'O.K.') AND (*LINK<=C'12'))
(((JV4,10,3)=C'NEU') OR (#TEMP.JV=C'Y') AND (*LINK2=X'00'))

Note

A conditional expression is evaluated “from inside to outside”, in accordance with the parentheses. On the same level of parenthesis, the logical operations are performed in the following order:

1. NOT
2. AND
3. OR
4. XOR

For example, the expression

(NOT (JV1=C'ABC') OR (JV2=C'Z') AND (JV3<>JV4))

is evaluated as

((NOT (JV1=C'ABC')) OR ((JV2=C'Z') AND (JV3<>JV4)))

When comparing job variable values, certain points must be kept in mind:

  • Relational expressions are evaluated one byte at a time from left to right. The appropriate bit pattern in EBCDIC code is decisive in determining the result of the
    comparison, e.g. the printable digits 0 through 9 (X'F0' through X'F9') are “greater” than the letters A through Z (X'C1' through X'E9'), and uppercase letters are greater than lowercase letters.

  • If the comparison value lies outside the definition range of a job variable or the job variable is empty (e.g. after a declaration), the result of the comparison is always “false”, even if the test is performed using “<>” (not equal).

  • If the contents of a job variable consist solely of binary zeros, it is not empty.
    Furthermore, if there are two otherwise identical job variable values, the one which is one binary zero longer is considered the greater of the two.

Example

The following expressions are “true”:

          C' ' < C'A'
          C'a' < C'A'                      X'81' < X'C1'
          C'A' < C'B'                    X'0123' < X'0124'
          C'B' < C'BB'                     X'C1' < X'C100'
C'GUTEN ABEND' < C'GUTEN MORGEN'
  C'ZZZZZZZZZ' < C'0'       (!)      X'F0F0F0F0' < X'F1'
          C'8' < C'9'
  C'899999999' < C'9'       (!)          X'3FFF' < C' '

The following queries are answered with “false”.

(IN)     CALL-PROCEDURE NAME=PROC.JV
(IN)     /.ANF BEGIN-PROCEDURE LOGGING=*ALL
(IN)     /CREATE-JV JV=JV1
(IN)     /SKIP-COMMANDS TO-LABEL=END,IF=*JV(CONDITION=((JV1,11,1) NE '2'))
(OUT)    %  CJC0011 SKIP COMMAND: CONDITION = FALSE
(IN)     /MODIFY-JV JV-CONTENTS=*SUBSTRING
(  )                (JV-NAME=JV1,POSITION=1,LENGTH=5),SET-VALUE=C'12345'
(IN)     /SKIP-COMMANDS TO-LABEL=END,IF=*JV(CONDITION=((JV1,6,2) EQ 'A1'))
(OUT)    %  CJC0011 SKIP COMMAND: CONDITION = FALSE
(IN)     /SKIP-COMMANDS TO-LABEL=END,IF=*JV(CONDITION=((JV1,6,2) NE 'A1'))
(OUT)    %  CJC0011 SKIP COMMAND: CONDITION = FALSE
(IN)     /.END END-PROCEDURE

A conditional expression is rejected in the following cases:

  1. A referenced JV is not accessible (catalog destroyed).

  2. A referenced JV does not exist in the specified catalog.

  3. The user is not authorized to access a JV which is either protected by a read password or not shareable.