The COMP keyword on BEGIN and FETCH directives

Purpose

A comparison expression lets you specify conditions when BEGIN and FETCH directives will be honored.

Syntax


1  COMP= ( + ., (  expression1
2.1 .EQ.
2.1 .NE.
2.1 .GE.
2.1 .GT.
2.1 .LE.
2.1 .LT.
1 (
1 + ., expression2
1 ) ) )

Parameters

expression1
This specifies a string made up of &-variables and alphanumeric literals. Any global search characters it contains are treated as literals. The value of expression1, arrived at by resolving any variables specified, will be tested against the values given by expression2.
.Operators.
These values are operators that specify which comparison should be made between expression1 and any expression2 values.
.EQ.
Expression1 must equal one of the expression2 values for the expression to be true.
.NE.
All expression2 values must not equal the expression1 value for the expression to be true.
.GT.
Expression1 must be greater than the expression2 value for the expression to be true.
.GE.
Expression1 must be greater than or equal to the expression2 value for the expression to be true.
.LT.
Expression1 must be less than the expression2 value for the expression to be true.
.LE.
Expression1 must be less than or equal to the expression2 value for the expression to be true.
expression2
This parameter can be made up of &-variables, literals, or, if .EQ. or .NE. operators are specified, one of the two global search characters, % and *.

The length of the resolved value cannot exceed 44 characters. The % global search character represents any single alphanumeric character. The * global search character represents any alphanumeric string, including a null string.

If GT, GE, LT, or LE is specified:
  • Multiple values of expression2 are not supported.
  • Global search characters are not supported.
  • If the strings on both sides of the operators are of different lengths, the comparison is made using the shorter string.
Note: The % symbol does not signify a % HCL Workload Automation for Z variable within a COMP keyword. The %- and ?- variables are not valid within a COMP statement.

Usage Notes

The COMP expression cannot exceed 256 characters unresolved, and cannot be more than 1024 characters after substitution; expression2 can be any &-variable, either user-defined or defined by HCL Workload Automation for Z. Neither expression1 nor expression2 can have embedded blanks.

Consider the following examples:

Example 1

//*%OPC FETCH PHASE=SETUP,
//*%OPC       MEMBER=MYJCL,
//*%OPC       COMP=(&APPL..EQ.(APPL1,APPL2,APPL3))

If &APPL. is equal to APPL1 or APPL2 or APPL3, the expression is true, and the FETCH directive will be honored.

Note the two periods following &APPL.. The first signifies the end of the variable APPL; the second signifies the start of the comparison operator EQ.

Example 2

//*%OPC FETCH PHASE=SETUP,
//*%OPC       MEMBER=MYJCL,
//*%OPC       COMP=(&DAY..NE.(1,3,5))

In example 2, if &DAY is not equal to 1 or 3 or 5, the expression is true, and the FETCH directive will be honored. If DAY had been equal to any one of the comparison values, the expression would have been false.

For the COMP keyword to be true, all the comparison expressions that it consists of must be true. This is shown in the following example:

Example 3

//*%OPC BEGIN ACTION=INCLUDE,
//*%OPC       COMP=((&APPL..EQ.(APPL1,APPL2,APPL3)),
//*%OPC             (&DAY..NE.(1,3,5)))
          .
          .
          .
//*%OPC END ACTION=INCLUDE

For the COMP statement in example 3 to be true, the expressions (&APPL..EQ.(APPL1,APPL2,APPL3)) and (&DAY..NE.(1,3,5)) must both be true.

The expression2 values that you specify can be made up of &-variables, alphanumeric literals, and the * and % global search characters. National characters, left and right parentheses; ( and ), and blanks are not allowed; if they are specified, the results are unpredictable. The * global search character represents a character string of any length; the % global search character represents exactly 1 character. If variables and global search characters are combined, the variables are resolved before any comparisons are made using the global search characters.

Example 4

//*%OPC BEGIN ACTION=INCLUDE,
//*%OPC       COMP=(&MYVAR..EQ.(TSO199,TSO2%%.,&VALUE1.*))
          .
          .
          .
//*%OPC END ACTION=INCLUDE

In example 4, the variable &MYVAR must have one of the following values for the comparison expression to be true:

  • TSO199
  • TSO2 followed by any 2 alphanumeric characters except blanks
  • The value of variable &VALUE1 followed by an alphanumeric string of any length, including length 0.

Example 5

//*%OPC BEGIN ACTION=EXCLUDE,PHASE=SUBMIT,
//*%OPC       COMP=(&CYYMMDD..GE.000101)
          .
          .
          .
//*%OPC END ACTION=EXCLUDE

Note that COMP statements can give unexpected results with some of the date formats of the supplied variables. When date variables are substituted, they are compared as numerals, not as dates.

In example 5, &CYYMMDD is the current date and 000101 represents 1 January 2000. If the value of expression1 is greater than 000101, the comparison expression is true—even though a date in the 20th century is earlier than 1 January 2000. You will also have problems with comparing dates specified in formats like DDMMYY or MMDDYY.