COMP (Comparison) keyword for display files

You use this field-level keyword to specify that the IBM® i operating system is to compare the data that the workstation user types into an input or input/output field with the specified value.

The relational operator is the criterion for the comparison. If the data typed in this field fails this validity check, the IBM i operating system displays an error message. Note that the IBM i operating system performs this checking only if the field is changed by the workstation user or if its modified data tag (MDT) is set on using DSPATR(MDT).

Note: See CHKMSGID (Check Message Identifier) keyword for display files for information about defining user-specified error messages.

The format of the keyword is:

COMP(relational-operator value)

You can specify only one operation for the COMP keyword and only one COMP keyword for a field.

The valid entries for the relational operator are:

Relational operator
Meaning
EQ
Equal
NE
Not equal
LT
Less than
NL
Not less than
GT
Greater than
NG
Not greater than
LE
Less than or equal
GE
Greater than or equal

The specified value must be either numeric or character, depending on the data type (decimal positions entry). Numeric values are expressed by the digits 0 through 9 and a leading sign (+ or -). Character values must be enclosed in single quotation marks.

Note: If the field you are defining is numeric, alignment is based on the decimal positions specified (in positions 36 and 37), and leading and trailing blanks are filled with zeros. If no decimal point is typed in, the decimal point is assumed to be to the right of the last (farthest right) digit. For example, for a numeric field with a length of 5 (specified in position 34) and 2 decimal positions (specified in position 37), 1.2 is interpreted as 001.20, and 100 is interpreted as 100.00.

You cannot specify the COMP keyword on a floating-point field (F in position 35).

Option indicators are not valid for this keyword.

Example

The following example shows how to specify the COMP keyword.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A            FIELD2         6  OI 10 10COMP(EQ +021920)
00020A            FIELD1         3   I 11 11COMP(EQ 'ABC')
     A