Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
how to validate whether a field has alphanumeric valueornot?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
ashesh choudhury

New User


Joined: 05 May 2008
Posts: 5
Location: mumbai

PostPosted: Wed Jun 04, 2008 8:57 pm    Post subject: how to validate whether a field has alphanumeric valueornot?
Reply with quote

i have a variable say A(6). how can i check whether the value present in the variable is alphanumeric or not? is there any special syntax for that?
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Wed Jun 04, 2008 9:27 pm    Post subject:
Reply with quote

what is A(6)? that is not a variable name or picture clause.

besides, everything is alphanumeric in singlebyte types.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


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

PostPosted: Wed Jun 04, 2008 9:34 pm    Post subject:
Reply with quote

Try looking at Checking for Alphanumeric data
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Jun 05, 2008 5:26 am    Post subject:
Reply with quote

Hi ashesh,

Just remember when reading the above thread, that 'A' THRU 'Z' and 'a' THRU 'z' will contain "junk" values.

If you have an IBM "green card" (or whatever its equivalent is these days) it will show you what the ranges need to be to eliminate those "junk" values.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Thu Jun 05, 2008 6:22 am    Post subject:
Reply with quote

Hello,

Quote:
how can i check whether the value present in the variable is alphanumeric or not
First, you need to define what are all of the "good" values for a byte (are lower-case letters valid or junk?). Then you need to define any other rules (for example, is an embedded space valid or not?).

Once the rules are defined, you can then implement code to enforce them. If you post all of the rules, we may be able to offer suggestions.
Back to top
View user's profile Send private message
yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Thu Jun 05, 2008 8:08 am    Post subject: Re: how to validate whether a field has alphanumeric valueor
Reply with quote

ashesh choudhury wrote:
i have a variable say A(6). how can i check whether the value present in the variable is alphanumeric or not?


Ashesh, if I am not wrong A(6) is your Picture Clause. 'A' is for ALPHABATIC PIC.


You can use SPECIAL-NAME for this one.


Yogeshwar
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Thu Jun 05, 2008 8:37 am    Post subject:
Reply with quote

Hello,

Please post your SPECIAL-NAME solution for the posted requirement.
Back to top
View user's profile Send private message
ashesh choudhury

New User


Joined: 05 May 2008
Posts: 5
Location: mumbai

PostPosted: Thu Jun 05, 2008 9:15 am    Post subject:
Reply with quote

Thanks for your replies.
Actually in the field everything EXCEPT special charecters are allowed.so can anybody provide a way to check whether the field contains any special charecter or not.
for example ,"ABC990' is allowed
but "*-/+@?" is not allowed.
Is there any way for ensuring this?
Back to top
View user's profile Send private message
yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Thu Jun 05, 2008 10:05 am    Post subject:
Reply with quote

dick scherrer wrote:
Hello,

Please post your SPECIAL-NAME solution for the posted requirement.



Here it is...

Code:

 ENVIRONMENT DIVISION.                         
 CONFIGURATION SECTION.                       
 SOURCE-COMPUTER.  IBM-370.                   
 OBJECT-COMPUTER.  IBM-370.                   
 SPECIAL-NAMES. CLASS VALID-DATA   '0' THRU '9'
                                   'A' THRU 'Z'.



Here VALID-DATA will work as ALPHANUMERIC CLASS, will check ALPHABETIC & NUMERIC values. If you want to add SPACES or any other symbol, you can add these to your VALID-DATA class.

Here, we are defining our own CLASS VALID-DATA.


We can use VALID-DATA as 'IS VALID-DATA' condition, similar of 'IS NUMERIC' check.

Code:


IF VARIABLE-NAME IS VALID-DATA
NEXT SENTENCE
ELSE
DISPLAY "VARIABLE-NAME is not ALPHANUMERIC".




Correct me If I am wrong.

Yogeshwar
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Thu Jun 05, 2008 11:59 am    Post subject:
Reply with quote

does defining the class as A thru Z,
will this define the value range as: x'C1' thru x'E9'
or as: x'C1' thru x'C9', x'D1' thru x'D9' and x'E1' thru x'E9'?
Back to top
View user's profile Send private message
yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Thu Jun 05, 2008 12:28 pm    Post subject: Reply to: how to validate whether a field has alphanumeric v
Reply with quote

Characters A thru Z are not contiguous.There are a few printables in there, like "\" AND "}" To be safe you should code it:

Code:


'A' THRU 'I'   'J' THRU 'R'   'S' THRU 'Z'   




For more help on SPECIAL-NAMES have a look on
This Thread
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Thu Jun 05, 2008 7:02 pm    Post subject:
Reply with quote

Hello,

Quote:
Correct me If I am wrong.
Yes, you are wrong. . . Your example allows characters that should not be allowed.

Quote:
Actually in the field everything EXCEPT special charecters are allowed
What about hex values that are not on the keyboard? I suspect those too should be rejected.

Look at my earliest post - you need to define exactly which characters are "good" and if there are any rules beyond a single-character validation. It is time to actually do the specification, not talk in generalaties. Once the specifics, some generalization is probably possible (i.e. A-I, etc). As has been mentioned A-Z is not correct.
Back to top
View user's profile Send private message
yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Fri Jun 06, 2008 7:26 am    Post subject: Re: Reply to: how to validate whether a field has alphanumer
Reply with quote

yogeshwar_ade wrote:
Characters A thru Z are not contiguous.There are a few printables in there, like "\" AND "}" To be safe you should code it:

Code:


'A' THRU 'I'   'J' THRU 'R'   'S' THRU 'Z'   






Thanks D for correcting me.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Fri Jun 06, 2008 7:51 am    Post subject:
Reply with quote

Hello,

Quote:
Thanks D for correcting me.
You're welcome, but i'd not have included that bit if i'd seen your earlier correction when i replied. Seems like a bit of strange magic. . .

Sorry for the overdose icon_redface.gif

Hopefully, TS has what is needed to implement the required code.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Validate the Date girishb2 DFSORT/ICETOOL 9 Tue Sep 19, 2017 1:12 am
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts JES2 job size field matching Windows ... SRICOBSAS All Other Mainframe Topics 4 Tue Sep 05, 2017 5:49 pm
No new posts Validate if a Value from the file is ... balacsv2 COBOL Programming 8 Mon Jun 19, 2017 11:52 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us