Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Check whether a field is NUMERIC or ALPHABETIC

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

Active User


Joined: 22 May 2009
Posts: 158
Location: Bangalore

PostPosted: Sat Jun 12, 2010 1:08 pm    Post subject: Check whether a field is NUMERIC or ALPHABETIC
Reply with quote

Hi,
I have a requirement to check whether a field is NUMERIC or ALPHABETIC.

i have a fields of say

Code:

     
                               01 FORIEGN  X(30)
                               01 IS-FOREIGN X(05)

                         When i move numeric bytes such as

                         MOVE 009125478987  TO FOREIGN
                         
                            IF FOREIGN IS NUMERIC
                               MOVE 'TRUE'   TO IS-FOREIGN
                            ELSE
                               MOVE 'FALSE' TO IS-FORIEGN
                            END-IF.
   

                             


Always the value of IS-FOREIGN is a FALSE.

Please can i get any solution on it to know wheteher a field is a perfect NUMERIC OR perfect ALPHABETIC.
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


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

PostPosted: Sat Jun 12, 2010 2:29 pm    Post subject:
Reply with quote

try moving 30 numeric characters!!!!!!
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Sat Jun 12, 2010 2:36 pm    Post subject:
Reply with quote

01 FORIEGN X(30)
IF FOREIGN

01 IS-FOREIGN X(05)
MOVE 'FALSE' TO IS-FORIEGN


As far as i see it the compiler will not even let you go that far
too test it.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Sat Jun 12, 2010 7:09 pm    Post subject:
Reply with quote

Quote:
Please can i get any solution on it to know wheteher a field is a perfect NUMERIC OR perfect ALPHABETIC.
Yes, if an alphanumeric variable contains numeric data the IF NUMERIC test will return true while if it contains just letters the IF ALPHABETIC test will return true. However, you must remember that if the variable is PIC X(30), you must have 30 digits for it to pass -- since you did not provide all 30 digits, the variable is filled with spaces which are NOT numeric. Hence the FALSE display.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Sat Jun 12, 2010 8:32 pm    Post subject:
Reply with quote

in case you are trying to proof for a NUMVALable values (char) in a char field (PIC X),
I always setup a user class/condition (in special names paragraph) that defines
what characters are allowed (will not cause an abend) for the NUMVAL or NUMVAL-C instructions.
Back to top
View user's profile Send private message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 158
Location: Bangalore

PostPosted: Sun Jun 13, 2010 12:21 pm    Post subject:
Reply with quote

Thanks for the reply.

so for my logic to work can i check till the field is having spaces and then go ahead with the check of numeric or alphabetic.does that work.
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: Sun Jun 13, 2010 12:41 pm    Post subject:
Reply with quote

tecnokrat wrote:
Please can i get any solution on it to know wheteher a field is a perfect NUMERIC OR perfect ALPHABETIC.
This is a very vague question, what exactly are you looking for?
Quote:
so for my logic to work can i check till the field is having spaces and then go ahead with the check of numeric or alphabetic.does that work.
Yes, sort of, again, less generalization and more specifics. There are a lot of answers here and a lot of expertise here, let us know just what you are trying to do.
Back to top
View user's profile Send private message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 158
Location: Bangalore

PostPosted: Sun Jun 13, 2010 2:50 pm    Post subject:
Reply with quote

as said to move the complete X(30) with NUM values to check it as IF NUMERIC then the exact result would be TRUE.

instead if only a partial NUM is present in X(30) say only 20 bytes and if only these 20 bytes can be checked with rest as spaces.
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: Sun Jun 13, 2010 3:06 pm    Post subject:
Reply with quote

tecnokrat wrote:
as said to move the complete X(30) with NUM values to check it as IF NUMERIC then the exact result would be TRUE.

instead if only a partial NUM is present in X(30) say only 20 bytes and if only these 20 bytes can be checked with rest as spaces.
I'm not sure where the question is, but NUMVAL or EXAMINE replacing the blanks with zeros might help....
Back to top
View user's profile Send private message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 158
Location: Bangalore

PostPosted: Sun Jun 13, 2010 3:35 pm    Post subject:
Reply with quote

if the exact value in the field X(30) has 00901213147600 and if the remaining is replaced with zeroes the exact value would have missed out.

The value intact cant be checked without replacing the spaces with zeroes.

and if the field has zeroes in the trailing then it would become tedious to know which one is real value,if added with zeroes with remaining spaces.
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: Sun Jun 13, 2010 3:55 pm    Post subject:
Reply with quote

tecnokrat wrote:
if the exact value in the field X(30) has 00901213147600 and if the remaining is replaced with zeroes the exact value would have missed out.

The value intact cant be checked without replacing the spaces with zeroes.

and if the field has zeroes in the trailing then it would become tedious to know which one is real value,if added with zeroes with remaining spaces.
Have you looked at NUMVAL?
That intrinsic function will convert you 30 byte character field down to a valid numeric field.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Sun Jun 13, 2010 3:56 pm    Post subject:
Reply with quote

tecnokrat,

you never bother to read the links provided,
thus your threads go on forever.

since no one could be that dense,
i figure that you are doing it on purpose in attempt to irritate posters to your thread.
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 Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us