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
 

 

Is Not numeric Not as expected

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Is Not numeric Not as expected
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
Warnings : 1

New User


Joined: 28 Apr 2005
Posts: 99

PostPosted: Thu May 26, 2005 3:14 pm    Post subject:
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    Post subject:
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
Warnings : 1

New User


Joined: 28 Apr 2005
Posts: 99

PostPosted: Thu May 26, 2005 4:36 pm    Post subject:
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    Post subject: Re: Is Not numeric Not as expected
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: 238
Location: USA

PostPosted: Sun Jun 05, 2005 2:34 am    Post subject:
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    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 Validate if a Value from the file is ... balacsv2 COBOL Programming 8 Mon Jun 19, 2017 11:52 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 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