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
 

 

comparing field to zero

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

New User


Joined: 19 Jun 2007
Posts: 50
Location: Chicago

PostPosted: Wed Apr 08, 2009 8:41 pm    Post subject: comparing field to zero
Reply with quote

Is there a compiler option or version that will accept a

05 SAVED-WALG-DEPT-NUMBER PIC 99.

field with X'40F0' as equal to zero?

IF SAVED-WALG-DEPT-NUMBER = ZERO
PERFORM BUILD-MB180203 THRU BUILD-MB180203-EXIT
GO TO BUILD-MB180200-EXIT.

I expected the alpha numeric field to be not equal and therefore
the build not be performed but instead the build actually occured?
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: Wed Apr 08, 2009 9:14 pm    Post subject:
Reply with quote

You could set an 88 level, but I'm not aware of any option to cause COBOL to treat X'40F0' as zero.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Wed Apr 08, 2009 9:47 pm    Post subject:
Reply with quote

You said, "alpha numeric field", but the field you show is numeric; which is it? Please paste exact definition, not a keyed version.
Back to top
View user's profile Send private message
lcmontanez

New User


Joined: 19 Jun 2007
Posts: 50
Location: Chicago

PostPosted: Wed Apr 08, 2009 9:57 pm    Post subject:
Reply with quote

The field is defined as numeric PIC 99 although the value is X'40F0' which
is alpha.

Cobol is not complaing/erroring out on having a blank in a numeric field.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Wed Apr 08, 2009 10:04 pm    Post subject:
Reply with quote

you should have:
Code:

IF SAVED-WALG-DEPT-NUMBER NUMERIC
THEN
    IF SAVED-WALG-DEPT-NUMBER = ZERO
        PERFORM BUILD-MB180203 THRU BUILD-MB180203-EXIT
        GO TO BUILD-MB180200-EXIT
    END-IF
ELSE
    PERFORM SAVED-WALG-DEPT-NUMBER-INVALID
    GO TO BUILD-MB180200-EXIT
END-IF.


NUMERIC DISPLAY (PIC 9) is famous for allowing any bullshit to be
mathematically manipulated without error.
my advice:
never use a NUMERIC DISPLAY field without first checking for NUMERIC
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: Wed Apr 08, 2009 10:56 pm    Post subject:
Reply with quote

Absolutely what Dick says about not using numeric display fields (and also not moving to a numeric display field unless you know for a fact that the sending data is numeric) -- somebody moved a variable with spaces to the field, and COBOL moved the two blanks in, then did the unsigned conversion to ensure the last byte is F0, and voila you have X'40F0' in a numeric field.
Back to top
View user's profile Send private message
lcmontanez

New User


Joined: 19 Jun 2007
Posts: 50
Location: Chicago

PostPosted: Thu Apr 09, 2009 12:20 am    Post subject:
Reply with quote

Thank you all for your comments.

I was more concern how the old process BASEV programs (combines Cobol/assem Arthur Anderson technique) would process a X'40F0' as
equal to zero but Cobol II was not (expected result).

I thought this was due to a compiler option or release version.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Thu Apr 09, 2009 12:30 am    Post subject:
Reply with quote

lcmontanez wrote:
I was more concern how the old process BASEV programs (combines Cobol/assem Arthur Anderson technique) would process a X'40F0' as equal to zero but Cobol II was not (expected result).

I thought this was due to a compiler option or release version.

No, probably the BASEV used a packed compare (since a PACK instruction would lose the 4) vs COBOL probably just does a character compare.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Thu Apr 09, 2009 12:31 am    Post subject:
Reply with quote

Quote:
Arthur Anderson technique


ah! there's your problem.
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 READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Alter &DATENS field in HEADER1 Angad DFSORT/ICETOOL 4 Mon Apr 24, 2017 11:49 am
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts outrec field outside range Danielle.Filteau SYNCSORT 10 Sat Mar 04, 2017 2:37 am


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