Class Condition

The class condition determines whether the content of a data item is alphabetic, alphabetic-lower, alphabetic-upper, numeric, 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.

Read syntax diagramSkip visual syntax diagram
Class Condition - Format

>>-identifier--+----+--+-----+--+-NUMERIC----------+-----------><
               '-IS-'  '-NOT-'  +-ALPHABETIC-------+   
                                +-ALPHABETIC-LOWER-+   
                                +-ALPHABETIC-UPPER-+   
                                |      (1)         |   
                                +-DBCS-------------+   
                                |       (1)        |   
                                +-KANJI------------+   
                                '-class-name-------'   

Notes:
  1. IBM Extension
identifier
Must reference a data item whose usage is DISPLAY. When the identifier is a group item of zero length and NOT is specified in the class condition, the result is always true. If NOT is not specified, the result is always false.

If identifier is a function identifier, it must reference an alphanumeric, DBCS, or date-time function.

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 a data item is nonnumeric.
NUMERIC
The data item consists entirely of the characters 0 through 9, with or without an operational sign.

If its PICTURE does not contain an operational sign, the item 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 item 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.

In the EBCDIC character set, valid embedded operational positive signs are hexadecimal F, C, E, and A. Negative signs are hexadecimal D and B. The preferred positive sign is hexadecimal F, and the preferred negative sign is hexadecimal D. For items described with the SIGN IS SEPARATE clause, valid operational signs are + (hex 4E) and - (hex 60).

IBM Extension

For numeric and date-time data items, the identifier being tested can be described implicitly or explicitly as USAGE DISPLAY, USAGE PACKED-DECIMAL, USAGE COMP, or USAGE COMP-3.

End of IBM Extension
ALPHABETIC
The data item referenced by the identifier consists entirely of any combination of the lowercase or uppercase alphabetic characters A through Z, and the space.
ALPHABETIC-LOWER
The data item referenced by the identifier consists entirely of any combination of the lowercase alphabetic characters a through z, and the space.
ALPHABETIC-UPPER
The data item referenced by the identifier consists entirely of any combination of the uppercase alphabetic characters A through Z, and the space.
class-name
The data item referenced by the identifier consists entirely of the characters listed in the definition of class-name in the SPECIAL-NAMES paragraph.

The class-name test must not be used with an identifier described as numeric.

IBM Extension
DBCS
Identifier consists entirely of DBCS characters, with the following rules:
  • For DBCS data items, the identifier being tested must be described explicitly or implicitly as USAGE DISPLAY-1.
  • A range check is performed on the data portion of the item for valid DBCS character representation. The valid range is X'41' through X'FE' for both bytes. X'4040' is a DBCS blank.
KANJI
Identifier consists entirely of DBCS characters, with the following rules:
  • For DBCS data items, the identifier being tested must be described explicitly or implicitly as USAGE DISPLAY-1.
  • A range check is performed on the data portion of the item for valid DBCS character representation. The valid range is X'41' through X'7F' for the first byte, and X'41' through X'FE' for the second byte. X'4040' is a DBCS blank.
End of IBM Extension

The class test is not valid for items whose usage is INDEX, POINTER, or PROCEDURE-POINTER because these items do not belong to any class or category.

IBM Extension

The class condition cannot be used for external floating-point (USAGE DISPLAY) or internal floating-point (USAGE COMP-1 and USAGE COMP-2) items.

End of IBM Extension

Table 1 shows valid forms of the class test.

Table 1. Valid Forms of the Class Test
Type of Identifier Valid Forms of the Class Test

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
Internal-Decimal

NUMERIC

NOT NUMERIC

IBM Extension

DBCS
DBCS-edited

End of IBM Extension

 
 
DBCS
KANJI

 
 
NOT DBCS
NOT KANJI

IBM Extension

Date-Time

End of IBM Extension

 
 
NUMERIC
class-name

 
 
NOT NUMERIC
NOT class-name