I need an edit, the field can be numeric, or alpha (no special characters), or a combination - alpha/numeric.
what is the test for this?
IF FIELD-A IS ALPHANUMERIC obviously isn't valid.
IF FIELD-A IS ALPHABETIC OR FIELD-A IS NUMERIC
just isn't the same thing.
However, if you test at the character level, this test will work, you just need to test all of the characters.
To accomplish this, just redefine the file as a table of one character entries with the same number of occurences as characters in the original field or use reference modification. Here's the reference modification version:
PERFORM VARYING CHAR-POSITION FROM 1 BY 1
UNTIL CHAR-POSITION > FIELD-LENGTH
IF FIELD-A (CHAR-POSITION: 1) NOT NUMERIC AND
FIELD-A (CHAR-POSITION: 1) NOT ALPHABETIC
DISPLAY 'FIELD NOT ALPHANUMERIC'
MOVE FIELD-LENGTH TO CHAR-POSITION
END-IF
END-PERFORM.
Obviously you can substitute appropriate logic for the DISPLAY.
Hope this helps
Betty Scherber
Brainbench MVP for COBOL II
You can define a CLASS in SPECIAL-NAMES defining the alfanumeric class the way you like. I don't know if this performs good but you can use it just like any other class test.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.