Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

alphanumeric tests

Status
Not open for further replies.

gman01

Programmer
Oct 28, 2005
1
0
0
US
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.
 
You're right there's no test for alphanumeric and

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.

I hope this is helpful.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top