Comparison Expression

Used to compare two values or to compare two character strings to determine if the first string matches or contains the second string.
idmscu19
Used to compare two values or to compare two character strings to determine if the first string matches or contains the second string.
Syntax
  ►►─┬─┬─ 
comparison-value
 ──────┬── 
operator
 ──┬─ 
comparison-value
 ──────┬─┬───►◄    │ └─ 
arithmetic-expression
 ─┘              └─ 
arithmetic-expression
 ─┘ │    │                                                                      │    └─ 
comparison-value
 ─┬─ CONTAINS ─┬─ 
comparison-value
 ─────────────────┘                         └─ MATCHES ──┘
Expansion of Comparison-Value
►►─┬─ 
literal
 ──────────────────────────────────────────────────────────┬─────►◄    ├─ 
data-field-name-variable
 ─────────────────────────────────────────┤    └─ 
lr-field-name
 ─┬────────────┬─┬───────────────────────┬─┬───────┬─┘                      └ OF 
lr-name
 ┘ │    ┌─────────────┐    │ └ OF LR ┘                                     └ ( ─▼─ 
subscript
 ─┴─ ) ┘  
Parameters
  • comparison-value
    Specifies the value to be compared.
    Expanded syntax for
    comparison-value
    is shown above immediately following the compression expression syntax.
  • arithmetic-expression
    Specifies an arithmetic expression, according to the rules presented in Arithmetic Expressions.
  • operator
    The comparison operators are:
Operator
Synonym
Meaning
EQ
=
Equal
NE
 
Not equal to
GT
>
Greater than
LT
<
Less than
GE
 
Greater than or equal to
LE
 
Less than or equal to
  • CONTAINS
    Searches the left operand for an occurrence of the right operand.
    The length of the right operand must be less than or equal to the length of the left operand, and both operands must be EBCDIC or unsigned zoned decimal data types. If the right operand is not entirely contained in the left operand, the outcome of the comparison is false.
  • MATCHES
    Compares the left operand to the right operand, one character at a time, beginning with the leftmost character in each operand. The right operand can contain mask characters, as follows:
    • @
      -- Matches any alphabetic character
    • #
      -- Matches any numeric character
    • *
      -- Matches any character
    Any other character in the right operand matches only itself in the left operand.
Expansion of Comparison-Value
  • literal
    A user-supplied variable, expressed as a numeric constant, or the character string itself, enclosed in single quotation marks.
  • data-field-name-variable
    Specifies the name of a variable data field, according to the rules presented in Variable Data Fields.
  • lr-field-name
    Specifies the name of a field in a Logical Record Facility record known to the subschema associated with the dialog.
  • OF
    lr-name
    Specifies the name of the record that contains the field referenced by
    lr-field-name
    .
    This clause is required only if the named field is not unique among the records known to the dialog.
  • subscript
    Specifies the applicable occurrence of the field referenced by
    lr-field-name
    . This can be a variable field containing the applicable occurrence, the occurrence itself, or an expression.
    This clause applies only if the named field is defined as a multiply-occurring field.
  • OF LR
    Specifies that the value of the named field at the time that the request is issued is used throughout processing of the request.
    If the value of the field changes during processing, LRF continues to use the original value. If OF LR is not specified and the value of the field changes during processing of the request, the new value in the dialog's record buffer is used for any further processing of the request.
Usage
Considerations
Both the left and right operands must be EBCDIC or unsigned zoned decimal data types. The length of the string that is compared is set to the length of the shorter of the two operands. If a character in the left operand does not match the corresponding character in the right operand, the outcome of the comparison is false.