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

comparing field to zero


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Apr 08, 2009 9:14 pm
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
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
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Apr 08, 2009 10:56 pm
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
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: 2146
Location: At my coffee table

PostPosted: Thu Apr 09, 2009 12:30 am
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts S0C7 - Field getting overlayed COBOL Programming 2
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
Search our Forums:

Back to Top