Summary -

In this topic, we described about the Class Condition with detailed example.

The class condition determines whether the content of a data item is alphabetic, alphabetic-lower, alphabetic-upper, numeric or contains only the characters specified by the CLASS clause as defined in the SPECIAL-NAMES paragraph of the environment division.

Syntax -

Class Condition Syntax

identifier-1 -

Specify a data item defined with one of the following usages -

  • DISPLAY, COMPUTATIONAL-3 or PACKED-DECIMAL when NUMERIC is specified
  • DISPLAY 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.

NOT -

NOT and the next keyword define the class test for truth value. For example, NOT NUMERIC is a truth test for determining 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 sign. If its PICTURE does not contain sign, the identifier being tested and determined to be numeric only if the contents are numeric and sign is not present.

If its PICTURE does contain sign, the identifier being tested and determined to be numeric only if the item is an elementary item, the contents are numeric, and a valid sign is present.

ALPHABETIC -

identifier-1 consists any combination of the lowercase or uppercase Latin alphabetic characters A through Z and the space.

ALPHABETIC-LOWER -

identifier-1 consists any combination of the lowercase Latin alphabetic characters a through z and the space.

ALPHABETIC-UPPER -

identifier-1 consists any combination of the uppercase Latin alphabetic characters A through Z and the space.

class-name -

identifier-1 consists of the characters listed in the definition of class-name in the SPECIAL-NAMES paragraph.

Valid forms of the class condition for different types of data items -

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
Numeric NUMERIC
class-name
NOT NUMERIC
NOT class-name