COMP (Comparison) keyword for physical and logical files

Use this field-level keyword to specify validity checking for the field you are defining when it is referred to later during display file creation. For logical files, you can also specify this keyword at the select/omit-field level. COMP is equivalent to CMP.

The format of the keyword is:
COMP(relational-operator value)
At the select/omit-field level, the format of the keyword is:
COMP(relational-operator field-name)
Valid relational operators are:
Relational operator
Meaning
EQ
Equal to
NE
Not equal to
LT
Less than
NL
Not less than
GT
Greater than
NG
Not greater than
LE
Less than or equal to
GE
Greater than or equal to

Specify the value parameter at either the field level or the select/omit field level. Specify the field name parameter only at the select/omit field level.

Example 1

The following example shows how to specify the COMP keyword for character and numeric strings.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A          R RECORD                    PFILE(PF1)
00020A
00030A            FIELDA         1  0       COMP(NE O)     1
C0040A            FIELDB         1          COMP(NE 'A')   1
00050A            FIELDC
00060A            FIELDD
00070A            FIELDE
00080A          K FIELDB
00090A          S FIELDC                    COMP(EQ FIELDD)   2
00100A          S FIELDA                    COMP(NE O)        2
00110A          S FIELDE                    COMP(NE *NULL)    2
00120A          O FIELDB                    COMP(GE 'A')      2
     A
1
COMP is specified for FIELDA and FIELDB as a validity checking keyword for display files that refer to FIELDA and FIELDB.
2
COMP is specified as a select/omit keyword for FIELDC, FIELDA, FIELDB, and FIELDE. Records from the physical file PF1 are retrieved through this logical file record format depending on the following comparisons:
  • FIELDC: Records are selected when FIELDC equals FIELDD.
  • FIELDA: Records not meeting FIELDC test are selected only when FIELDA is not equal to zero.
  • FIELDE: Records not meeting FIELDA test are selected only when FIELDE is not the null value.

Example 2

The following example specifies the COMP keyword using a hexadecimal character string.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A          R RCD1                      PFILE(PF1)
00020A            CODEA
00030A            FLD1
00040A            FLD2
00050A          K FLD1
00060A          S CODEA                     COMP(EQ X'51')
     A

COMP is specified as a select/omit keyword for CODEA (which is a 1-byte field). Records from physical file PF1 are retrieved through this record format only if the value of field CODEA is hex 51.

Related reference
CMP (Comparison) keyword for physical and logical files