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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking for Alphanumeric in COBOL370 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I know you can have a statement checking "if field not numeric", I tried using the same type statement checking for "not alphanumeric" and I am not able to do so. Maybe the syntax is wrong. Anyone know of a way to check a field for alphanumeric characters. I have look at the field and know there is junk in there. HELP!!!
 
There is not phrase "not alphanumeric". The three types of data are numeric (9's), alphanumeric (x), and alphabetic (a) - I don't know if anyone uses the last type anymore.

Does your program use the alphabetic type? If not you could just use

if <dataitem> is numeric
<do something>
else
<stmts for all non-numeric >

This is just the reverse of saying
if <dataitem> is not numeric
<non-numeric stmts>
else
<stmts for numeric data>

I don't remember if there's an alpha syntax - hen you could do
if <dataitem> is numeric
<stmts>
else if <dataitem> is alpha
<stmts>
else
<stmts for alphanumeric>

Does this help?
 
Hi sajxsn,

The SPECIAL-NAMES paragraph is tailor made for this kind of problem.

It appears in the CONFIGURATION SECTION of the ENVIRONMENT-
DIVISION and is coded something like this:

SPECIAL-NAMES. CLASS your-an-name IS 'A THRU Z 1 THRU 9'.
(if you want to include special chars, you can.)

In your proc div, you code:

IF NOT your-an-name etc.

This approach can be used wherever you need to test a string for the presence of any characters, for example:

If a 1 byte field you're interrogating can only contain one of 15 values that are not contiguous, you can use SPECIAL-
NAMES and validate it with only 1 IF statement.

Hope this helps. Jack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top