IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Is Not numeric Not as expected


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
nageshkothakota

New User


Joined: 26 May 2005
Posts: 1

PostPosted: Thu May 26, 2005 12:57 pm
Reply with quote

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
View user's profile Send private message
Deepa.m

New User


Joined: 28 Apr 2005
Posts: 99

PostPosted: Thu May 26, 2005 3:14 pm
Reply with quote

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
View user's profile Send private message
vasanthanc

New User


Joined: 01 Apr 2005
Posts: 58

PostPosted: Thu May 26, 2005 4:14 pm
Reply with quote

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
View user's profile Send private message
Deepa.m

New User


Joined: 28 Apr 2005
Posts: 99

PostPosted: Thu May 26, 2005 4:36 pm
Reply with quote

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
View user's profile Send private message
Ashutosh Shrinet

New User


Joined: 22 Aug 2004
Posts: 10
Location: New Delhi

PostPosted: Thu Jun 02, 2005 9:16 am
Reply with quote

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
View user's profile Send private message
mdtendulkar

Active User


Joined: 29 Jul 2003
Posts: 237
Location: USA

PostPosted: Sun Jun 05, 2005 2:34 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Convert HEX to Numeric DB2 3
No new posts Find a record count/numeric is multip... COBOL Programming 1
No new posts Handling the numeric data in unstring... COBOL Programming 18
No new posts Search file for records that don't fo... SYNCSORT 8
Search our Forums:

Back to Top