sign in
 
   
 
 
 
   
  COBOL TUTORIAL FOR BCA STUDENTS OF M G UNIVERSITY  
  UNIT 4: PROCEDURE DIVISION . . .  
   
 

CLASS CONDITION

 
   
 

The class condition determines whether or not the value of an operand is numeric or alphabetic. An operand is numeric if it contains only the digits 0 to 9 with or without an operational sign. An operand is alphabetic if it contains only the letters A to Z and space.

The format of the class condition is as follows:

 
   
 

The class condition is very useful for the validation of the input data.

The following rules apply in the case of a class condition:

1. The usage of the identifier must be DISPLAY or some forms of DISPLAY.

2. For the NUMERIC option the identifier must be either numeric or alphanumeric. If the data item is defined with an operational sign (picture contains S or a SIGN clause has been specified), then the appearance of sign (zoned in the units position or a leading or trailing sign, as the case may be) is considered to be normal.

3. For the alphabetic option, the identifier must be either alphabetic or alphanumeric.

4. The identifier may be a group item. However, for the NUMERIC option, the group item must not contain elementary items described with an operational sign.


Example:

 
 
77 BASIC-PAY PIC 9(5) V99.

Having read the value for BASIC-PAY we can test the value of BASIC-PAY to ensure that the data on the card is actually numeric.

This can be done as follows:

IF BASIC-PAY IS NOT NUMERIC GO TO PARA-ERROR.
 
 

If the data contains any character other than digits, control will be transferred to PARA-ERROR. Otherwise, control will go to the next sentence in sequence. It may be noted that the data must be written with leading zeros, if any, and not with leading spaces. The space character is considered to be an alphabetic character.