Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

checking if NUMERIC
In a discussion with a vendor he mentioned an issue with a numeric field
(USAGE DISPLAY PIC 9(9) or whatever) not having numeric data in it.  I
mentioned that I simply check if the field is NUMERIC prior to attempting to
use it further.  Here is his response:

"I'm used to using COBOL under MVS (Z/OS) where you get a "data exception"
error whenever you access a numeric field containing non-numeric data - even

if you're just asking if the field is "NUMERIC".  Therefore, we had to
define the numeric field as alphanumeric (or as a group level field) and
then if this definition was numeric we could then access the field using its

numeric definition.  A real pain.  It sounds like VSE/ESA has this problem
sorted."

This does not appear to me to be accurate.  Can anyone shed some light on
the subject?

Thanks,
Frank


Report this thread to moderator Post Follow-up to this message
Old Post
Frank Swarbrick
10-10-07 11:55 PM


Re: checking if NUMERIC
Easy answer.  They're WRONG.  (And as far as I know they were never correct)
.

1) See
http://publibz.boulder.ibm.com/cgi-...gy3lr31/6.1.6.2
for rules that explicitly ALLOW testing of NUMERIC

2) You don't *always* get a data exception when referencing a numeric data i
tem
when it has invalid data.  For a discussion of this they should see the
Migration Guide and look at the NUMPROC compiler option.

--
Bill Klein
wmklein <at> ix.netcom.com
"Frank Swarbrick" <Frank.Swarbrick@efirstbank.com> wrote in message
news:470C97B6.6F0F.0085.0@efirstbank.com...
> In a discussion with a vendor he mentioned an issue with a numeric field
> (USAGE DISPLAY PIC 9(9) or whatever) not having numeric data in it.  I
> mentioned that I simply check if the field is NUMERIC prior to attempting 
to
> use it further.  Here is his response:
>
> "I'm used to using COBOL under MVS (Z/OS) where you get a "data exception"
> error whenever you access a numeric field containing non-numeric data - ev
en
>
> if you're just asking if the field is "NUMERIC".  Therefore, we had to
> define the numeric field as alphanumeric (or as a group level field) and
> then if this definition was numeric we could then access the field using i
ts
>
> numeric definition.  A real pain.  It sounds like VSE/ESA has this problem
> sorted."
>
> This does not appear to me to be accurate.  Can anyone shed some light on
> the subject?
>
> Thanks,
> Frank
>



Report this thread to moderator Post Follow-up to this message
Old Post
William M. Klein
10-10-07 11:55 PM


Re: checking if NUMERIC
Thanks, Bill.  I had a hard time imagining that this issue ever actually
existed.  I'm guessing the vendor is getting this issue  with some
other issue.

n 10/10/2007 at 12:08 PM, in message
<Ly8Pi.91443$6L.44713@fe03.news.easynews.com>, William M.
Klein<wmklein@nospam.netcom.com> wrote:
> Easy answer.  They're WRONG.  (And as far as I know they were never
> correct).
>
> 1) See
>
> http://publibz.boulder.ibm.com/cgi-...S/igy3lr31/6.1.
> 6.2
> for rules that explicitly ALLOW testing of NUMERIC
>
> 2) You don't *always* get a data exception when referencing a numeric
> data item
> when it has invalid data.  For a discussion of this they should see the
> Migration Guide and look at the NUMPROC compiler option.

Report this thread to moderator Post Follow-up to this message
Old Post
Frank Swarbrick
10-10-07 11:55 PM


Re: checking if NUMERIC
William M. Klein wrote:
> Easy answer.  They're WRONG.  (And as far as I know they were never correc
t).
>
> 1) See
>    http://publibz.boulder.ibm.com/cgi-...y.home.att.net/

Report this thread to moderator Post Follow-up to this message
Old Post
Arnold Trembley
10-11-07 08:55 AM


Re: checking if NUMERIC
On Wed, 10 Oct 2007 09:13:26 -0600, "Frank Swarbrick"
<Frank.Swarbrick@efirstbank.com> wrote:

>if you're just asking if the field is "NUMERIC".  Therefore, we had to
>define the numeric field as alphanumeric (or as a group level field) and
>then if this definition was numeric we could then access the field using it
s
>
>numeric definition.  A real pain.  It sounds like VSE/ESA has this problem
>sorted."
>
>This does not appear to me to be accurate.  Can anyone shed some light on
>the subject?

Maybe it's a mainframe issue - I have been doing so for years (not
tested lately) because I found this to be a requirement.

Report this thread to moderator Post Follow-up to this message
Old Post
Howard Brazee
10-16-07 11:55 PM


Re: checking if NUMERIC
Howard,
What have you been doing for years?  Certainly every IBM mainframe compilers
for YEARS has allowed for the IF NUMERIC test on numeric fields.

--
Bill Klein
wmklein <at> ix.netcom.com
"Howard Brazee" <howard@brazee.net> wrote in message
 news:3pn9h31b1pfdn8e5ie4r0ml8hh0fq0gest@
4ax.com...
> On Wed, 10 Oct 2007 09:13:26 -0600, "Frank Swarbrick"
> <Frank.Swarbrick@efirstbank.com> wrote:
> 
>
> Maybe it's a mainframe issue - I have been doing so for years (not
> tested lately) because I found this to be a requirement.



Report this thread to moderator Post Follow-up to this message
Old Post
William M. Klein
10-16-07 11:55 PM


Re: checking if NUMERIC
On Tue, 16 Oct 2007 19:55:17 GMT, "William M. Klein"
<wmklein@nospam.netcom.com> wrote:

>Howard,
>  What have you been doing for years?  Certainly every IBM mainframe compil
ers
>for YEARS has allowed for the IF NUMERIC test on numeric fields.

I might have used a different compiler on a different computer when I
developed this habit.

Report this thread to moderator Post Follow-up to this message
Old Post
Howard Brazee
10-16-07 11:55 PM


Re: checking if NUMERIC

"William M. Klein" <wmklein@nospam.netcom.com> wrote in message
news:EG8Ri.134871$zt4.81850@fe08.news.easynews.com...
> Howard,
>  What have you been doing for years?  Certainly every IBM mainframe
> compilers for YEARS has allowed for the IF NUMERIC test on numeric fields.
>

Yes, they have, and it is totally illogical.

A numeric field, by definition, should be numeric. IBM hardware has  always
allowed crap in numeric fields and then interrupted the OS when it is
detected. Therefore, they HAD to allow a Class test on numeric fields for
COBOL, so that programmers could detect the crap and take action to avoid
the program being aborted.

The alternative is to simply let incorrect numeric values be processed (and
several platforms I have worked on did this). It was surprising how careful
programmers became after a few instances of incorrect results being
produced...

The IBM way is NOT the ONLY way, and some of the alternatives are more
logical, although they don't provide the "safety net" that S0C7 does.

If a field is defined as ALPHANUMERIC it can hold anything, and it therefore
makes sense to apply a Class test on it. It does NOT make sense to apply a
Class test to a field defined as ALPHABETIC or NUMERIC (because, by
definition, the contents MUST be ALPHABETIC or NUMERIC), and the only reason
you need to do so is because of sloppy programming, and the fact that the
hardware may crash your program if you don't.

Sure, everybody has moved spaces to a group level that included numeric
fields, and then suffered the consequences (at least on IBM hardware), but
that's a good argument for using INITIALIZE.

I remember in the old days you could test a field for numeric, it would
pass, and it would STILL be wrong... The test had to be "NUMERIC and
POSITIVE" to ensure that zoned sign overpunches were not  with an
alphabetic character, inadvertently introduced into the card. Again, an
illogical workaround, necessitated by inadequate hardware.

For myself, the ONLY time I would use a Class test is on an ALPHANUMERIC
field (PIC X).

And even then it would probably be because I had lost the plot (or was
validating raw input); if you don't know whether the contents of your data
fields are what they are supposed to be or not, then maybe truck driving
might be a better occupation for you... :-)

Validation of raw input excepted, to me, using a Class test is simply poor
programming.

Pete.
--
"I used to write COBOL...now I can do anything."


> --
> Bill Klein
> wmklein <at> ix.netcom.com
> "Howard Brazee" <howard@brazee.net> wrote in message
>  news:3pn9h31b1pfdn8e5ie4r0ml8hh0fq0gest@
4ax.com... 
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Pete Dashwood
10-16-07 11:55 PM


Re: checking if NUMERIC
"Howard Brazee" <howard@brazee.net> wrote:
> "William M. Klein" <wmklein@nospam.netcom.com> wrote:
> 
>
> I might have used a different compiler on a different computer when I
> developed this habit.

A number of years ago (10-20?) I remember having a problem with one
COBOL compiler where invalid (non numeric) data caused a program fault
when you tested a display numeric item for "IF NUMERIC". It worked if
it was only the zone bits that were wrong, but if you had a hex value of
A-F in the numeric bits, the program crashed. IIRC, it was the Unisys A
Series COBOL74 compiler.
--
Judson McClendon      judmc@sunvaley0.com (remove zero)
Sun Valley Systems     http://sunvaley.com
"For God so loved the world that He gave His only begotten Son, that
whoever believes in Him should not perish but have everlasting life."



Report this thread to moderator Post Follow-up to this message
Old Post
Judson McClendon
10-17-07 02:55 AM


Re: checking if NUMERIC
On Wed, 17 Oct 2007 12:30:33 +1300, "Pete Dashwood" <dashwood@removethis.ent
ernet.co.nz>
wrote:

>
>
>"William M. Klein" <wmklein@nospam.netcom.com> wrote in message
>news:EG8Ri.134871$zt4.81850@fe08.news.easynews.com... 
>
>Yes, they have, and it is totally illogical.
>
>A numeric field, by definition, should be numeric. IBM hardware has  always
>allowed crap in numeric fields and then interrupted the OS when it is
>detected. Therefore, they HAD to allow a Class test on numeric fields for
>COBOL, so that programmers could detect the crap and take action to avoid
>the program being aborted.
>
>The alternative is to simply let incorrect numeric values be processed (and
>several platforms I have worked on did this). It was surprising how careful
>programmers became after a few instances of incorrect results being
>produced...
>
>The IBM way is NOT the ONLY way, and some of the alternatives are more
>logical, although they don't provide the "safety net" that S0C7 does.
>
>If a field is defined as ALPHANUMERIC it can hold anything, and it therefor
e
>makes sense to apply a Class test on it. It does NOT make sense to apply a
>Class test to a field defined as ALPHABETIC or NUMERIC (because, by
>definition, the contents MUST be ALPHABETIC or NUMERIC), and the only reaso
n
>you need to do so is because of sloppy programming, and the fact that the
>hardware may crash your program if you don't.
>
>Sure, everybody has moved spaces to a group level that included numeric
>fields, and then suffered the consequences (at least on IBM hardware), but
>that's a good argument for using INITIALIZE.
>
>I remember in the old days you could test a field for numeric, it would
>pass, and it would STILL be wrong... The test had to be "NUMERIC and
>POSITIVE" to ensure that zoned sign overpunches were not  with an
>alphabetic character, inadvertently introduced into the card. Again, an
>illogical workaround, necessitated by inadequate hardware.
>
>For myself, the ONLY time I would use a Class test is on an ALPHANUMERIC
>field (PIC X).
>
>And even then it would probably be because I had lost the plot (or was
>validating raw input); if you don't know whether the contents of your data
>fields are what they are supposed to be or not, then maybe truck driving
>might be a better occupation for you... :-)
>
>Validation of raw input excepted, to me, using a Class test is simply poor
>programming.

You cannot test packed decimal for numeric using a group name, nor can you t
est a signed
number. I think a NUMERIC test on PIC X is illogical, because the definition
 of numeric is
ambiguous.  A NUMERIC test on PIC X acts as though the PIC is all 9s, unsign
ed. If that's
the type you intend, it would be clearer to say so explicitly.

The '02 Standard introduced VALIDATE. When applied to a group name (such as 
a record), it
tests each elementary field individually, according to its picture.

Report this thread to moderator Post Follow-up to this message
Old Post
Robert
10-17-07 02:55 AM


Sponsored Links




Last Thread Next Thread Next
Pages (6): [1] 2 3 4 5 6 »
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Forum Jump:
All times are GMT. The time now is 08:13 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.