Class condition
The class condition determines whether the content of a data item is alphabetic, alphabetic-lower, alphabetic-upper, numeric, DBCS, KANJI, or contains only the characters in the set of characters specified by the CLASS clause as defined in the SPECIAL-NAMES paragraph of the ENVIRONMENT DIVISION.
- identifier-1
- Must reference a data item described with one of the following
usages:
- DISPLAY, NATIONAL, COMPUTATIONAL-3, or PACKED-DECIMAL when NUMERIC is specified
- DISPLAY-1 when DBCS or KANJI is specified
- DISPLAY or NATIONAL when ALPHABETIC, ALPHABETIC-UPPER, or ALPHABETIC-LOWER is specified
- DISPLAY when class-name is specified
Must not be of class alphabetic when NUMERIC is specified.
Must not be of class numeric when ALPHABETIC, ALPHABETIC-UPPER, or ALPHABETIC-LOWER is specified.
Table 1 lists the forms of class condition that are valid for each type of identifier.
If identifier-1 is a function-identifier, it must reference an alphanumeric or national function.
An alphanumeric group item can be used in a class condition where an elementary alphanumeric item can be used, except that the NUMERIC class condition cannot be used if the group contains one or more signed elementary items.
When identifier-1 is described with usage NATIONAL, the class-condition tests for the national character representation of the characters associated with the specified character class. For example, specifying a class condition of the form
IF national-item IS ALPHABETIC
is a test for the lowercase and uppercase letters Latin capital letter A through Latin capital letter Z and the space, as represented in national characters. SpecifyingIF national-item is NUMERIC
is a test for the characters 0 through 9.When identifier-1 is described with usage UTF-8, the class-condition tests for the UTF-8 character representation of the characters associated with the specified character class. For example, specifying a class condition of the form
IF utf8-item IS ALPHABETIC
is a test for the lowercase and uppercase letters Latin capital letter A through Latin capital letter Z and the space, as represented by UTF-8 characters. - NOT
- When used, NOT and the next keyword define the class test to be executed for truth value. For example, NOT NUMERIC is a truth test for determining that the result of a NUMERIC class test is false (in other words, the item contains data that is nonnumeric).
- NUMERIC
- identifier-1 consists entirely
of the characters 0 through 9, with or without an operational sign.
If its PICTURE does not contain an operational sign, the identifier being tested is determined to be numeric only if the contents are numeric and an operational sign is not present.
If its PICTURE does contain an operational sign, the identifier being tested is determined to be numeric only if the item is an elementary item, the contents are numeric, and a valid operational sign is present.
Usage note: Valid operational signs are determined from the setting of the NUMCLS installation option and the NUMPROC compiler option. For more information, see Checking for incompatible data (numeric class test) in the Enterprise COBOL Programming Guide.
- ALPHABETIC
- identifier-1 consists entirely of any combination of the lowercase or uppercase Latin alphabetic characters A through Z and the space.
- ALPHABETIC-LOWER
- identifier-1 consists entirely of any combination of the lowercase Latin alphabetic characters a through z and the space.
- ALPHABETIC-UPPER
- identifier-1 consists entirely of any combination of the uppercase Latin alphabetic characters A through Z and the space.
- class-name
- identifier-1 consists entirely of the characters listed in the definition of class-name in the SPECIAL-NAMES paragraph.
- DBCS
- identifier-1 consists
entirely of DBCS characters.
A range check is performed on the item for valid character representation. The valid range is X'41' through X'FE' for both bytes of each DBCS character and X'4040' for the DBCS blank.
- KANJI
- identifier-1 consists entirely of
DBCS characters.
A range check is performed on the item for valid character representation. The valid range is from X'41' through X'7E' for the first byte, from X'41' through X'FE' for the second byte, and X'4040' for the DBCS blank.
Type of data item referenced by identifier-1 | Valid forms of the class condition | |
---|---|---|
Alphabetic | ALPHABETIC
ALPHABETIC-LOWER ALPHABETIC-UPPER class-name |
NOT ALPHABETIC
NOT ALPHABETIC-LOWER NOT ALPHABETIC-UPPER NOT class-name |
Alphanumeric, alphanumeric-edited, or numeric-edited | ALPHABETIC
ALPHABETIC-LOWER ALPHABETIC-UPPER NUMERIC class-name |
NOT ALPHABETIC
NOT ALPHABETIC-LOWER NOT ALPHABETIC-UPPER NOT NUMERIC NOT class-name |
External-decimal
or internal-decimal |
NUMERIC | NOT NUMERIC |
DBCS | DBCS
KANJI |
NOT DBCS
NOT KANJI |
National | NUMERIC
ALPHABETIC ALPHABETIC-LOWER ALPHABETIC-UPPER |
NOT NUMERIC
NOT ALPHABETIC NOT ALPHABETIC-LOWER NOT ALPHABETIC-UPPER |
Numeric | NUMERIC
class-name |
NOT NUMERIC
NOT class-name |