View previous topic :: View next topic
|
Author |
Message |
lizzy
New User
Joined: 28 Jul 2008 Posts: 3 Location: Philippines
|
|
|
|
Hello there.. can I ask how to validate a pic s9(9)v99 if it is numeric.. and can it be redefined as a picture x with the sign still in it? |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Why do you think you have to redefine it? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
If you just want to know if the field is numeric, IF <var name> NUMERIC works fine. If you want to guarantee it to be numeric, use BIF DEEDIT. And I'm not sure what you mean by
Quote: |
and can it be redefined as a picture x with the sign still in it? |
since you can definitely redefine the field as PIC X(11), and the sign won't be touched. Of course, if you start using the PIC X field like it's a numeric field, the sign overlay may cause problems. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
One little "opportunity" with COBOL validating signed-numeric fields is that if it's defined as signed, but yet (as a possibility in this example), the zone-nibble of the last byte contains a 4-Bit "F" instead of a 4-Bit "C" or "D", it may fail the NUMERIC test.
I've seen this happen with signed packed-decimal which had an "F" sign-nibble, so it may also occur with display-numeric signed.
Regards,
Bill |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Bill, that'll depend on the NUMPROC setting for the compile and the site NUMCLS setting. Depending on how these are set, the 4-bit 'F' may or may not cause the NUMERIC test to fail. Good catch! |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Robert,
Yeah that's true. However, I've always recommended the default NUMPROC(NOPFD) to all of our programmers.
I'd rather see a "CP" get an equal condition (or a SOC7) rather than NUMPROC(PFD) get a non-equal with a "CLC", because you won't get a SOC7 with a "CLC" until later on down the road when some TRUE arithmetic instruction is used.
IMHO, NUMPROC(PFD) can hide potential bad data, unless of course, data-integrity has been assured beforehand.
Regards,
Bill |
|
Back to top |
|
|
lizzy
New User
Joined: 28 Jul 2008 Posts: 3 Location: Philippines
|
|
|
|
Thank you for all your replies. I am really beginner on cics programming. Your right Bill my variable failed the 'is numeric' test. What I am thinking is in its BMS map the picin is not defined, so it will be a pic x then move it in pic s9 after checking it byte per byte excluding the sign? What do you think?
Also what is the best way of removing trailing spaces of a number inputted by a user in a map? Inspect keyword doesn't work in cics.
I'll check my compiler tomorrow.
I really appreciate all your help!!
Thanks guys |
|
Back to top |
|
|
|