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

How to validate a pic s9(9)v99 if it is numeric.


IBM Mainframe Forums -> CICS
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
lizzy

New User


Joined: 28 Jul 2008
Posts: 3
Location: Philippines

PostPosted: Wed Jul 30, 2008 8:08 pm
Reply with quote

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
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Jul 30, 2008 8:16 pm
Reply with quote

Why do you think you have to redefine it?
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 Jul 30, 2008 8:22 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Jul 30, 2008 8:42 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Jul 30, 2008 9:18 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Jul 30, 2008 9:31 pm
Reply with quote

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. icon_wink.gif

IMHO, NUMPROC(PFD) can hide potential bad data, unless of course, data-integrity has been assured beforehand.

Regards,

Bill
Back to top
View user's profile Send private message
lizzy

New User


Joined: 28 Jul 2008
Posts: 3
Location: Philippines

PostPosted: Thu Jul 31, 2008 8:18 pm
Reply with quote

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 icon_biggrin.gif
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 -> CICS

 


Similar Topics
Topic Forum Replies
No new posts Convert HEX to Numeric DB2 3
No new posts Find a record count/numeric is multip... COBOL Programming 1
No new posts Handling the numeric data in unstring... COBOL Programming 18
No new posts Need to validate the field using cobol COBOL Programming 4
No new posts JSONVALID to validate the JSON PL/I & Assembler 4
Search our Forums:

Back to Top