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: 7935
Location: Bellevue, IA

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: 1239
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: 6966
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: 7935
Location: Bellevue, IA

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: 6966
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 INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am


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