View previous topic :: View next topic
|
Author |
Message |
nageshkothakota
New User
Joined: 26 May 2005 Posts: 1
|
|
|
|
Hi,
I am trying to find whether the value in field WS-VAR is numeric
the field is defined as WS-VAR PIC 9(07)
IF WS-VAR IS NOT NUMERIC
DISPLAY "NOT NUMERIC " WS-VAR
END-IF
when the input value is 3000 it is still displaying "NOT NUMERIC 3000"
Requesting for any clues....
cobol : z/os and os/390 version 3.1.0 |
|
Back to top |
|
|
Deepa.m
New User
Joined: 28 Apr 2005 Posts: 99
|
|
|
|
definitely it should work as expected.. The reason for not working may be due leading/trialing spaces.
Can you give us more information like where do you fetch the data for
ws-var. Is it read form file? sa this piece os code u provided is flawless. |
|
Back to top |
|
|
vasanthanc
New User
Joined: 01 Apr 2005 Posts: 58
|
|
|
|
as Deepa said, there could be leading blanks. Try to remove the leading blanks using
INSPECT WS-VAR
TALLYING WS-BLANK-LEN FOR LEADING SPACES
IF WS-VAR(1 + WS-BLANK-LEN:) IS NOT NUMERIC
by the above code, u can eliminate the leading spaces. Have a try and let me know if it works |
|
Back to top |
|
|
Deepa.m
New User
Joined: 28 Apr 2005 Posts: 99
|
|
|
|
u can even pad WS-VAR with leading zeros and execute..It will work
for eg give 0003000 instead of 3000 and check the output. |
|
Back to top |
|
|
Ashutosh Shrinet
New User
Joined: 22 Aug 2004 Posts: 10 Location: New Delhi
|
|
|
|
hi
this is ashutosh. the answer to ur query is that its working perfectly fine at my end, not numeric clause checks whether the variable is numeric or not and will result to true when the variable is not numeric. check it again and if there's any prob kindly let me know
biiiiiiiiiiiiiii |
|
Back to top |
|
|
mdtendulkar
Active User
Joined: 29 Jul 2003 Posts: 237 Location: USA
|
|
|
|
nageshkothakota,
Code: |
INITIALIZE WS-VAR
MOVE 3000 TO WS-VAR
IF WS-VAR IS NOT NUMERIC
DISPLAY "NOT NUMERIC " WS-VAR
END-IF |
This should solve your problem
Hope this helps,
Regards
Mayuresh |
|
Back to top |
|
|
|