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
 

 

Issue with the numeric comparison.

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

New User


Joined: 26 Sep 2008
Posts: 84
Location: Chennai

PostPosted: Thu Jul 07, 2011 10:47 pm    Post subject: Issue with the numeric comparison.
Reply with quote

Hi,

I have field ws-x pic x(7) = +004.00 . I have converted it to numeric using FUNCTION NUMVAL into variable WS-Y pic +9(3).9(2) = +004.00 .

Now when if am validating the variable WS-Y as

If ( WS-Y is Numeric )

Perform -a
Else
Perform- b

As i am expecting value to be numeric and control should go to a
but it's performing B.


Then i Tried

If ( WS-Y) >= 0

Perform -a
Else
Perform- b

Still control is going to b.

Please advise Why the comparison is happening so....

Hex value for variable WS-Y is
Code:
4EF0F0F44BF0F0


Thanks..
Back to top
View user's profile Send private message

Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Jul 07, 2011 11:01 pm    Post subject: Reply to: Issue with the numeric comparison.
Reply with quote

Move the numeric value into a PIC S9(03)V9(02) field and then try the NUMERIC check.

This "feature" was introduced with COBOL/370 (the successor to VS/COBOL II) and was unofficially dubbed "De-Editing".

Bill
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8117
Location: East Dubuque, Illinois, USA

PostPosted: Thu Jul 07, 2011 11:24 pm    Post subject:
Reply with quote

If you click on the Manuals link at the top of the page, find the COBOL Language Reference guide, and read section 6.1.6.2 on class conditions you will find
Quote:
NUMERIC
identifier-1 consists entirely of the characters 0 through 9, with or without an operational sign.

If its PICTURE does not contain an operational sign, the identifier being tested is determined to be numeric only if the contents are numeric and an operational sign is not present.

If its PICTURE does contain an operational sign, the identifier being tested is determined to be numeric only if the item is an elementary item, the contents are numeric, and a valid operational sign is present.

Note: Valid operational signs are determined from the setting of the NUMCLS installation option and the NUMPROC compiler option. For more information, see the Enterprise COBOL Programming Guide .
Your variable WS-Y contains somethiing other than digits 0 through 9 and an operational sign -- the decimal point. That prevents it from meeting the NUMERIC class condition.

And if you notice the hex value you posted, it starts X'4E'. Since a zero is X'F0', your IF WS-Y > 0 test will fail as well. COBOL does exactly what you told it to do -- whether or not that is what you meant for it to do.
Back to top
View user's profile Send private message
Amsar

New User


Joined: 26 Sep 2008
Posts: 84
Location: Chennai

PostPosted: Fri Jul 08, 2011 12:11 am    Post subject: Reply to: Issue with the numeric comparison.
Reply with quote

Robert and Bill,

Thanks a lot for the information and your valuable time.

I have tried option suggested by Bill by moving the variable in s9(3)v(2)
and it worked perfect.

Thanks again!!!
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 Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
No new posts Execessive parameter issue Sumeendar JCL & VSAM 5 Mon Dec 19, 2016 4:35 pm


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