Validity Checking for Display Files

Use CHECK at the field level to specify that the OS/400 program or the device is to check the validity of the data typed into an input-capable (input-only or output/input) field.

CHECK validates the data by applying one or more edit/check algorithms against the data. An error message is displayed if a specified edit/check algorithm is not satisfied.

Note:
See CHKMSGID (Check Message Identifier) Keyword for Display Files for information on defining user-specified messages.

The valid edit/check codes are:

Edit/Check Code
Meaning

AB
Allow blanks

ME
Mandatory enter

MF
Mandatory fill

M10
IBM Modulus 10 self-check algorithm

M10F
IBM Modulus 10 self-check algorithm

M11
IBM Modulus 11 self-check algorithm

M11F
IBM Modulus 11 self-check algorithm

VN
Validate name

VNE
Validate name extended

AB (Allow Blanks) for Display Files

Use this code at the file, record, or field level to allow all-blank input to satisfy validity checking for an input-capable field should any associated validity check fail. This enables the passing of data to the program when the work station user has positioned the cursor to the field but left it blank (for instance, by pressing the Erase Input key, the Field Exit key, or the spacebar). For example, FLD1 is an input-capable field with CHECK(M10 ME) in effect. If the work station user accidentally types into the field, the M10 algorithm must be satisfied. Specifying (CHECK(M10 ME AB)) allows the display station user to blank the field to satisfy validity checking.

When specified at the file level, this keyword applies for all input-capable fields in the file for which a validity checking keyword is coded. Likewise, when specified at the record level, this keyword applies for all input-capable fields in the record for which a validity checking keyword is coded. At the field level, always specify this keyword with another validity checking keyword (CHECK(M10, M10F, M11, M11F, VN, VNE), CHKMSGID, COMP, RANGE, or VALUES).

CHECK(AB) should not be specified if SFLROLVAL or SFLRCDNBR is also specified for the field.

CHECK(AB) can be used in database files for reference purposes.

When you consider using CHECK(AB) with other validity checking functions, note that processing occurs in the following order:

  1. Any of the following:
    1. The keyboard shift attribute specified in position 35 (such as alphanumeric shift or numeric only) can restrict input keying to certain characters.
    2. If the keyboard shift attribute is numeric shift, the data type (character or numeric) is set by the entry in positions 36 through 37 (decimal positions) and restricts input keying to certain characters.
    3. The CHECK(FE), CHECK(MF), and CHECK(ME) keywords, if specified, restrict input keying.
  2. Either of the following:
    1. If CHECK(AB) is specified, data management passes the input data to the program (blanks for a character field and zeros for a numeric field). No further validity checking is done.
    2. If CHECK(AB) is not specified, data management performs the following validity checking functions before passing the data to the program: CHECK(VN), CHECK(VNE), CHECK(M10), CHECK(M10F), CHECK(M11), CHECK(M11F), COMP(. . .), RANGE(. . .), VALUES(. . .).

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

Option indicators are not valid for this keyword.

ME (Mandatory Enter) for Display Files

This code specifies that at least 1 character of data (a blank is valid) must be typed into the field. Note that when no field currently on the display has been changed, the display station does not enforce mandatory enter. To enforce mandatory enter, specify DSPATR(MDT) for at least one field in each record on the display. For all other fields in the record, CHECK(ME) is then enforced. However, because the device cannot determine if the user has typed data to a field with both DSPATR(MDT) and CHECK(ME), you should also specify DSPATR(ND) so that this field is not displayed.

Option indicators are valid for this keyword.

MF (Mandatory Fill) for Display Files

This code specifies that if any part of the field is altered, each position in the field must have a character entered in it. Blanks are considered valid characters.

This code cannot be specified with keyboard control codes (RB or RZ) or with the WRDWRAP keyword.

Option indicators are not valid for this keyword.

M10/M10F or M11/M11F (IBM Modulus 10 or Modulus 11 Algorithm) for Display Files

This code specifies that data typed into the field must satisfy the IBM Modulus 10 (M10 or M10F) or Modulus 11 (M11 or M11F) self-check algorithm. When you specify CHECK(M10) or CHECK(M11), the self-check verifies that the field has a valid Modulus 10 or Modulus 11 number when you press the Enter key or a function key. When you specify CHECK(M10F) or CHECK(M11F), the self-check verifies that the field has a valid Modulus 10 or Modulus 11 number as the user types the data into the field. You cannot specify both the Modulus 10 and the Modulus 11 self-check algorithms for the same field or both formats of the same algorithm for the same field.

A self-check field is composed of two parts: the base number and one check digit. The check digit is the farthest right digit in the field. The base number and the check digit together make up a field in your database (for example, an account number). The following illustration is an example of an 8-digit self-check field.



Example of an 8-digit self-check field

See the Application Display Programming book for information on how to use CHECK(M10), CHECK(M10F), CHECK(M11), and CHECK(M11F).

Notes:

  1. The OS/400 program supports a maximum length of 31 digits for numeric fields.

  2. You cannot specify the CHECK(M10), CHECK(M10F), CHECK(M11), and CHECK(M11F) keywords with the COMP(EQ) keyword.

  3. You cannot specify the CHECK(M10), CHECK(M10F), CHECK(M11), and CHECK(M11F) keywords on a floating-point field (F in position 35).

  4. You cannot specify the CHECK(M10F) or the CHECK(M11F) keyword in a file containing the USRDSPMGT keyword.

  5. You cannot specify the CHECK(M10F) or the CHECK(M11F) keyword on a field containing the CHKMSGID or WRDWRAP keyword.

For each position in the base number, there is a Modulus 10 weight factor and a Modulus 11 weight factor. Positions are counted from the farthest right digit (not including the check digit).

The Modulus 10 weight factor is 2 for positions 1, 3, 5, ..., 31. It is 1 for positions 2, 4, 6, ..., 30. The Modulus 11 weight factors are 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7,..., 2, 3, 4, 5, 6, 7, 2 for positions 1, 2,..., 31, respectively.

To calculate the Modulus 10 self-check digit, do the following:

  1. Multiply the units position and every alternate position of the base number by 2.
  2. Add the digits in the products to the digits in the base number that were not multiplied.
  3. Subtract the sum from the next higher number ending in zero.

The difference is the self-check digit.

To calculate the Modulus 11 self-check digit, do the following:

  1. Assign a weight factor to each digit position of the base number. These factors are: 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 2, 3, . . . starting with the units position of the number and progressing toward the high-order digit. For example, the base number 991246351 would be assigned the weight factors as follows:
    Base number       9 9 1 2 4 6 3 5 1
    Weight factors    4 3 2 7 6 5 4 3 2
    
  2. Multiply each digit by its weight factor.
  3. Add the products.
  4. Divide this sum by 11.
  5. Subtract the remainder from 11.

The difference is the self-check digit.

For example:

Base number
1 3 7 3 9

Weight factors
x6 x5 x4 x3 x2

Multiply each digit by its weight factor
6 15 28 9 18

Add the products
6 + 15 + 28 + 9 + 18 = 76

Divide the sum by 11
76/11 = 6 plus a remainder of 10

Subtract the remainder from 11
11 - 10 = 1

Self-check digit
1
Note:
If the remainder in step 4 is 0, the self-check digit is 0. If the remainder is 1, the base number has no self-check digit; you must make sure that such base numbers are not used in the fields you define as self-check fields.

Option indicators are not valid for CHECK(M10), CHECK(M10F), CHECK(M11), or CHECK(M11F).

VN (Validate Name) for Display Files

Use this code to specify that the data typed into the field must be a valid simple name. The first character must be $, #, @, or A through Z. The remaining characters must be alphanumeric ($, #, @, A through Z, 0 through 9, or underscore (_), and must not contain embedded blanks.

When the CHECK(VN) keyword is specified on a field, the field must be character (keyboard shift of A, N, X, W, or I), and must be input-capable (usage of I or B).

CHECK(VN) cannot be specified with any of the following keywords:

CHECK(M10)
CHECK(M10F)
CHECK(M11)
CHECK(M11F)
CHECK(VNE)
COMP
RANGE
VALUES

Option indicators are not valid for this keyword.

VNE (Validate Name Extended) in Display Files

Use this code to specify that the data typed into the field must be a valid extended name.

When the CHECK(VNE) keyword is specified on a field, the field must be character (keyboard shift of A, N, X, W, or I), input-capable (usage of I or B), and have a maximum length of 255 characters.

If the name is not delimited by double quotation marks:

If the name is delimited by double quotation marks:

CHECK(VNE) cannot be specified with any of the following keywords:

CHECK(M10)
CHECK(M10F)
CHECK(M11)
CHECK(M11F)
CHECK(VN)
COMP
RANGE
VALUES

Option indicators are not valid for this keyword.