Previous Topic: Attribute State Variables ValidationNext Topic: Optionality


Domain

One aspect of the validity of a data item is the domain. If a variable is defined as character, then the value may be any byte value from x'00' - x'FF'. For signed zoned, the range of legal values is different. The domain checks are summarized for each data type. Also, note that the verification domain checking logic must perform this test such that it is not susceptible to abnormal termination.

The following table lists domain checking rules.

Data Type

Domain Checking Rules

Character

Any byte may be from x'00' through x'FF', inclusive.

Unsigned zoned decimal

Each byte must contain a valid numeric, in the range of 0 - 9. Each byte must have a zone value of x'F' (x'F0 - x'F9').

Signed zoned decimal

Each byte must contain a valid numeric BCD encoding for digits 0 - 9. All bytes except the right-most byte must have a zone value of: x'F'. The last byte must have a zone value of x'F', x'C', or x'D'.

Unsigned short

Value may range from 0 to 65535 (x'0000' through x'FFFF'.

Signed short

Value may range from -32768 to +32767 (x'8000' through x'7FFF' in 2's complement notation.

Unsigned long

Value may range from 0 to 4,294,967,295 (x'00000000' through x'FFFFFFFF'.

Signed long

Value may range from -2.147,483,648 to +2,147,483,647 (x'8000000' through x'7FFFFFF' in 2's complement notation.

Packed decimal

All nibbles of all bytes must have the value 0 - 9. The only exception is the low order nibble of the last byte. It must be: x'C', x'D', or x'F'. Based on the principles of operation for IBM mainframes, x'F', is legal. However, COBOL recognizes only x'C' and x'D'.

Time

In addition to the validation rules for unsigned zoned decimal, the time must adhere to the format HHMMSS. where:

HH represents the hours specified as 00 - 23, or 24 if all other components are zero.

MM represents the minutes specified in the range from 00 - 59.

SS represents the seconds specified in the range from 00 - 59.

Date

In addition to the validation rules for unsigned zoned decimal, the date must adhere to the format YYYYMMDD. where:

YYYY represents the four-digit year.

MM represents the 2-digit month of the year.

DD represents the two-digit day of the month.

The value must specify a valid month for the specified year. The day of the month must be a valid specification for a day within the indicated month and year. This check must account for leap years and centuries, as well as Gregorian calendar anomalies. A value of zero for the entire date value is legal for optional date fields.

Timestamp

In addition to the validation rules for unsigned zoned decimal, the timestamp must adhere to the rules for its date and time components.
A value of zero for the entire timestamp is legal for optional timestamp fields.
A value of zero for the date components, but a non-zero time component is an illegal combination in all cases.
The microseconds component must be from 0 to 999999, inclusive.