IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Checking for Alphanumeric data


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Thu Sep 06, 2007 7:02 pm
Reply with quote

My reqt is to check whether the data in the field is alphanumeric or not. I have seen people using the "IS NUMERIC" and "IS ALPHABETIC" clause. Is there any such thing for searching for alphanumeric data?

I had thought of moving that to 9() and check for numeric + moving to A() and check for alphabetic but it wont work as my field is having data as the combination of alphabetic and numerals. say B14

I searched in this forum before posting but couldn't get the details.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Sep 06, 2007 7:15 pm
Reply with quote

Hello,

One school of thought is that everything is alphanumeric.

I suspect that is not your case.

Please clarify your requirement (i.e. define what values are "alphanumeric" to your process).
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Thu Sep 06, 2007 7:20 pm
Reply with quote

Some junk values are getting populated in a field. I need to check if the field is populated with alphanumeric data.

The check should pass if the field is populated with say B15 ( this is just an example ) the test shd fail if the field is populated with junk values.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu Sep 06, 2007 7:41 pm
Reply with quote

In SPECIAL-NAMES, CLASS class-name 'A' THRU 'Z' '0' thru '9' and
IF data-area IS (NOT) class-name......

CLASS clause
Class condition
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Sep 06, 2007 8:56 pm
Reply with quote

Hello,

Quote:
The check should pass if the field is populated with say B15 ( this is just an example ) the test shd fail if the field is populated with junk values.
This is not a clarification. . . It just restates your original post.

How should a comma in the data be treated? How about a period? Other readable characters on the keyboard?

You need to define "junk".

What CG posted may be exactly what you want. You may have additional requirements. . .
Back to top
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Thu Sep 06, 2007 10:42 pm
Reply with quote

My 2 cents. Define the field as a working storage group level - if it is not packed, then move what you need to look at into that field. Look at each field in that group as an individual. Flag fields in an array for not numeric. Anything that is NOT 0-9 is NOT NUMERIC.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri Sep 07, 2007 11:31 am
Reply with quote

Quote:
How should a comma in the data be treated? How about a period? Other readable characters on the keyboard?
You need to define "junk".


Comma,period and all other characters other than numerals and alphabets should be treated as junk.
Back to top
View user's profile Send private message
ashokm

New User


Joined: 28 Feb 2006
Posts: 11
Location: Chennai,India

PostPosted: Fri Sep 07, 2007 1:24 pm
Reply with quote

Hi Aaru,

Like this we can check what ever the char under JUNK

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
CLASS JUNK IS
'A' THRU 'Z'
'a'THRU 'z ‘
','
'+'
'.'
' '.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
01 WS-ALPHANUMERIC PIC X(10) VALUE 'B14’.
PROCEDURE DIVISION.
IF WS-ALPHANUMERIC IS JUNK
DISPLAY'JUNK'
ELSE
DISPLAY'NOT JUNK' .
STOP RUN.

Thanks & Reagrds
Ashok M
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri Sep 07, 2007 4:54 pm
Reply with quote

Thanks ashok and others for the reply.

Quote:
Look at each field in that group as an individual. Flag fields in an array for not numeric


This should be the best option.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Fri Sep 07, 2007 5:59 pm
Reply with quote

Aaru wrote:
Quote:
Look at each field in that group as an individual. Flag fields in an array for not numeric
This should be the best option.
Actually that is the most labor intensive and least simple way....Your requirement is exactly what the CLASS test was designed for....
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri Sep 07, 2007 6:05 pm
Reply with quote

Oh Ok. Thanks CICS Guy.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Store the data for fixed length COBOL Programming 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
No new posts JCL EXEC PARM data in C Java & MQSeries 2
Search our Forums:

Back to Top