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
 
Check whether this is numeric or Alphanumeric field

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

New User


Joined: 26 Apr 2007
Posts: 37
Location: USA

PostPosted: Mon Aug 13, 2007 11:00 pm    Post subject: Check whether this is numeric or Alphanumeric field
Reply with quote

Hi,
I have searched in forum but i did not get .. please help me.

how can we check whether this is numeric or Alphanumeric field.

For Ex,,
01 ws-field Pic X(08).
in this feild , eg. AAA, AA122, 1222, 122A, 11A12, AA-12,12-124,
so numeric means only numbers.. other than numbers are alphanumeric.. iam clear now.

so i would like to know in this field wether numeric or alpha numeric

Thank you
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Mon Aug 13, 2007 11:05 pm    Post subject:
Reply with quote

IF ws-field NUMERIC.......
But leading or trailing blanks or spaces will be considered alphanumeric too. What do you want to do if is is numeric?
Back to top
View user's profile Send private message
srebba
Warnings : 1

New User


Joined: 26 Apr 2007
Posts: 37
Location: USA

PostPosted: Mon Aug 13, 2007 11:10 pm    Post subject: Re: Numeric check
Reply with quote

Hi,

No, I need whehter numeric or alphanumeric..

In my program , if numeric i want to pass one variable,, if alphanumeric then pass to another variable.
i want to check wether alphanumerics or numeric only are in this field..
please let me know
thank u
Back to top
View user's profile Send private message
srebba
Warnings : 1

New User


Joined: 26 Apr 2007
Posts: 37
Location: USA

PostPosted: Mon Aug 13, 2007 11:12 pm    Post subject: Re: Numeric check
Reply with quote

in X(8) length... '122 ' . its numeric.. so spaces also considered numeric.. My aim is in this field , whether numeric or alphanumerics.

please let me know if iam not clear
thank u
Back to top
View user's profile Send private message
rpuhlman

New User


Joined: 11 Jun 2007
Posts: 80
Location: Columbus, Ohio

PostPosted: Mon Aug 13, 2007 11:30 pm    Post subject:
Reply with quote

Hi Sree,

One thing you can do is move ws-field to an intermediate field of the same attributes and then INSPECT ws-field-r REPLACING ALL SPACES WITH ZEROS. At this point you can evaluate whether ws-field-r is numeric or not. I'm not sure as to what extent you are trying to filter this data, just be aware that if you have a space in between numbers, such as '12 34 56' this will make it numeric ... any combination of numbers and spaces will become numeric after the inspect. Hope this helps.

Rick
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: Tue Aug 14, 2007 12:11 am    Post subject:
Reply with quote

Hello Sree,

If you will post several 8-byte values including spaces, numbers, letters, and "other" characters as well as the "result" you want the code to determine, we will be able to offer suggestions.

For example one example might be |12345678| (the |s are boundary markers) which would be numeric.

Depending on your particular rules | 1234| could be numeric or not numeric - you need to provide the definition.

The same is true for any other data format that might need to be processed. If you will post your "input"s and how they should be treated using the "Code" tag, it will be far easier to read - notice how my second value has the spaces "squeezed" out - a feature of text rather than Code.

If you click Preview before you Submit your post, you can see how your post will appear to everyone.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Tue Aug 14, 2007 1:16 am    Post subject: Re: Numeric check
Reply with quote

srebba wrote:
so spaces also considered numeric.
Depending on how you want to handle an all spaces field....

This one treats all spaces as numeric
Code:
Examine ws-field replacing spaces with zeros
If ws-field not numeric
   do not numeric thing
else
   if ws-field = zero
      do all spaces thing
   else
      do numeric thing
   end-if
end-if

This one allows all spaces to be treated which-ever way you want, numeric or not numeric
Code:
Perform varying x from 1 by 1
   until x > length of ws-field
      or not-numeric
   if ws-field(x:1) = space
      add 1 to space-count
   else
      if ws-field(x:1) not numeric
         set not-numeric to true
      end-if
   end-if
end-perform
if space-count = length of ws-field
   do zero thing
else
   if not numeric
      do not numeric thing
   else
      do numeric thing
   end-if
end-if
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: Tue Aug 14, 2007 1:23 am    Post subject:
Reply with quote

Hello,

Quote:
This one treats all spaces as numeric
Code:
Code:
Examine ws-field replacing spaces with zeros
If ws-field not numeric
   do not numeric thing
else
   if ws-field = zero
      do all spaces thing
   else
      do numeric thing
   end-if


With this code, |12 45 78| would become |12045078|, which i suspect would not be the desired result icon_confused.gif
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Tue Aug 14, 2007 1:31 am    Post subject:
Reply with quote

He did say, "so spaces also considered numeric".....
You are right though, imbedded spaces might not be treated the same as leading or trailing spaces...I'll wait for a judgment before I account for the possibility.... icon_lol.gif
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: Tue Aug 14, 2007 1:51 am    Post subject:
Reply with quote

For my $.02, the embedded spaces should be "not numeric", but we'll see what the rules for this case are . . .
Back to top
View user's profile Send private message
srebba
Warnings : 1

New User


Joined: 26 Apr 2007
Posts: 37
Location: USA

PostPosted: Tue Aug 14, 2007 11:57 pm    Post subject: Reply to: Check whether this is numeric or Alphanumeric fiel
Reply with quote

Thanks fro your help..

really this is very usefull forum...

thank u
Sree
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: Wed Aug 15, 2007 12:53 am    Post subject:
Reply with quote

You're welcome icon_smile.gif

We are still looking for some of your sample data and the processing rules.

If you have moved beyond this question, other people could learn if you post your solution.
Back to top
View user's profile Send private message
Bharath Nadipally

New User


Joined: 24 Jun 2008
Posts: 22
Location: Hyderabad

PostPosted: Wed Jun 25, 2008 10:53 am    Post subject:
Reply with quote

I am new to this forum. Please correct me if anything is wrong

How about this way?

1) Find out the size of the content(total size - no of trailing spaces)
2) IF substring(x,size) IS NUMERIC
do numeric thing
else
do non-numeric thing
(Here i am assuming '12 34' kind of data will not come.
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: Wed Jun 25, 2008 11:17 am    Post subject:
Reply with quote

Hello Kumar and welcome to the forums,

Quote:
I am new to this forum. Please correct me if anything is wrong
Nothing actually "wrong" but you have replied to a topic that has been inactive for almost a year icon_smile.gif

Quote:
Here i am assuming '12 34' kind of data will not come.
The person who asked the question never did provide the requested info, so we never found out if this was possible or not.
Back to top
View user's profile Send private message
sasikaran

New User


Joined: 24 Jun 2008
Posts: 3
Location: chennai

PostPosted: Wed Jun 25, 2008 12:44 pm    Post subject: Reply to: Check whether this is numeric or Alphanumeric fiel
Reply with quote

Let me share my thoughts..

It will be treated as Alphanumeric until all the bytes are occupied with numbers.

If a single byte is space or alphabetic it will be considered as Alphanumeric only.
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 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 Return a Non Numeric value from REXX Learncoholic CLIST & REXX 3 Fri Sep 01, 2017 8:33 pm
No new posts Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am
No new posts ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm

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