ILE COBOL Programmer's Guide

How to Do a Numeric Class Test

You can use the numeric class test to perform data validation. For example:

LINKAGE SECTION.
01   COUNT-X     PIC 999.
   .
   .
   .
   PROCEDURE DIVISION USING COUNT-X.
     IF COUNT-X IS NUMERIC THEN DISPLAY "DATA IS GOOD".
   .
   .
   .

The numeric class test checks the contents of a data item against a set of values that are valid for the particular PICTURE and USAGE of the data item. For example, a packed decimal item would be checked for hexadecimal values X'0' through X'9' in the digit positions, and for a valid sign value in the sign position (whether separate or non-separate).


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]