Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Help !! Numeric field in COBOL
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
sunil  
View profile  
 More options Jul 29 1997, 3:00 am
Newsgroups: comp.lang.cobol, alt.cobol
From: su...@aquas.com
Date: 1997/07/29
Subject: Help !! Numeric field in COBOL

Hi,

i need immediate help regarding handling of numeric field in COBOL85
on
HP 3000 platform.

I have a field like 9(12)V9(6). I want to check if the field is
numeric or if it has any alphanumeric character. Is there a function
call
i can use to do a quick check ?

I am reading a  field from input file as 9(12)V9(6). I am then putting
this field in the database (ingres). Before putting in Ingres database
i want to perform a check to make sure that the field is NUMERIC.

Please let me know if there is a function which can be used. If not,
do
you have a code which does this check ? THanks, Sunil

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William Lynch  
View profile  
 More options Jul 30 1997, 3:00 am
Newsgroups: comp.lang.cobol, alt.cobol
From: "William Lynch" <Lync...@worldnet.att.net>
Date: 1997/07/30
Subject: Re: Help !! Numeric field in COBOL

If the field is WS-DOLLAR-AMOUNT, you can code:

IF  WS-DOLLAR-AMOUNT NUMERIC ...

            or

IF  WS-DOLLAR-AMOUNT NOT NUMERIC ...

It's a good edit check for any numeric field from outside your system.

Bill Lynch


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bruce D. Sinclair  
View profile  
 More options Jul 30 1997, 3:00 am
Newsgroups: comp.lang.cobol, alt.cobol
From: "Bruce D. Sinclair" <sincl...@comland.com>
Date: 1997/07/30
Subject: Re: Help !! Numeric field in COBOL

If it's a DISPLAY usage data item, COBOL has the NUMERIC class
test for determining if the item is a valid numeric data item.  For
example,
if the data item's data-name is VALUE01, then

        IF VALUE01 IS NUMERIC
                {put in database}
        ELSE
                {display error message}
        END-IF

verifies that VALUE01 contains only valid digits.  If the data item were
signed, the NUMERIC class test also validates that the item has a
valid sign in the correct position (leading or trailing, combined or
separate).
Some COBOL implementations extend the NUMERIC class test to work
for PACKED-DECIMAL (aka COMP-3) usage data items.  If the data item
is BINARY (aka COMP or COMP-4) usage, then there is no way to validate
the item (other than it conforms to the PICTURE restrictions), so few,
if any, implementations allow a NUMERIC class test on such items.

--Bruce Sinclair, Liant Software Corporation

su...@aquas.com wrote in article <870222262.31...@dejanews.com>...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bill Herron  
View profile  
 More options Jul 30 1997, 3:00 am
Newsgroups: comp.lang.cobol, alt.cobol
From: "Bill Herron" <wher...@sprintmail.com>
Date: 1997/07/30
Subject: Re: Help !! Numeric field in COBOL

> i need immediate help regarding handling of numeric field in COBOL85 on
> HP 3000 platform.

This problem is general to all COBOL situations.

> I have a field like 9(12)V9(6). I want to check if the field is numeric
or if it has any
> alphanumeric character. Is there a function call i can use to do a quick

check ?

How about using the IS NUMERIC condition on the field:

     01  WS-FIELD                                      PIC 9(12)V9(6).

     IF WS-FIELD IS NUMERIC
     THEN
          save to database.

If that doesn't work, you can try a less elegant approach:

     01  WS-FIELD                                      PIC 9(12)V9(6).
     01  WS-FIELD-CHAR REDEFINES WS-FIELD
                                                                PIC 9(01)
OCCURS 18 TIMES.

Then use a loop to see if each WS-FIELD-CHAR is greater than 0 or less than
9.  The problem here is that you may get an error if an alphabetic is in
one of these positions.

So use

     01  WS-FIELD-CHAR REDEFINES WS-FIELD
                                                                PIC X(01)
OCCURS 18 TIMES.

Then check to see if each WS-FIELD-CHAR is greater than '0' and less than
'9'.

There may be other solutions to this (and I'm sure my fellow posters will
have them).  This should get you on the right track, though.

Bill

 -------------==== Posted via Sexzilla News ====------------------
    http://www.sexzilla.com        Search, Read, Post to Usenet
 -------------====   With A Whole Lot More  ====------------------


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sabine Rother-Scholz  
View profile  
 More options Jul 30 1997, 3:00 am
Newsgroups: comp.lang.cobol, alt.cobol
From: Sabine Rother-Scholz <Sabine.Rother-Sch...@rt.bosch.de>
Date: 1997/07/30
Subject: Re: Help !! Numeric field in COBOL

(snip)

How about

        01  WS-FIELD-X.
            05  WS-FIELD                                PIC 9(12)V9(6).

        IF WS-FIELD-X IS NUMERIC ....

Testing a numeric-defined field could be a problem. But group-fields are
always handled as alpha-numeric.

Greetings
Sabine


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
LeFew  
View profile  
 More options Jul 30 1997, 3:00 am
Newsgroups: alt.cobol
From: le...@aol.com (LeFew)
Date: 1997/07/30
Subject: Re: Help !! Numeric field in COBOL

It sounds as if you are answering your own question.  Redefine your field
as alphanumeric (some compilers will allow a 'type' trap if the data is
alphanumeric) and simply ask "if field numeric...else...!  


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »