View previous topic :: View next topic
|
Author |
Message |
tecnokrat Warnings : 1 Active User
Joined: 22 May 2009 Posts: 160 Location: Bangalore
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
try moving 30 numeric characters!!!!!! |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
tecnokrat Warnings : 1 Active User
Joined: 22 May 2009 Posts: 160 Location: Bangalore
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
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 |
|
|
tecnokrat Warnings : 1 Active User
Joined: 22 May 2009 Posts: 160 Location: Bangalore
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
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 |
|
|
tecnokrat Warnings : 1 Active User
Joined: 22 May 2009 Posts: 160 Location: Bangalore
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
|