MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to check for Numeric data

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
Meena_ramanathan
Beginner


Joined: 25 Oct 2005
Posts: 11
Topics: 7

PostPosted: Fri Jan 20, 2006 11:37 am    Post subject: How to check for Numeric data Reply with quote

Hi,

I have a variable
Ws-PRICE S9(6)V999
i want to check if this variable is numeric.
If i give WS_PRICE as ABCDE and When i use the "IS NUMERIC" class to test i donot error the record whereas it is accpeting ABCDE value.

I already tried searching the various posts , but could not get a solution.
Can someone help?

Thanks.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Fri Jan 20, 2006 1:16 pm    Post subject: Reply with quote

Quote:

If i give WS_PRICE as ABCDE and When i use the "IS NUMERIC" class to test i donot error the record whereas it is accpeting ABCDE value.


huh ? can you show us how you moved abcde to a numeric item ?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Meena_ramanathan
Beginner


Joined: 25 Oct 2005
Posts: 11
Topics: 7

PostPosted: Fri Jan 20, 2006 1:24 pm    Post subject: Reply with quote

Hi,

this is the how the field is shown in fileaid.
This is the display when the field has a numeric data

AFLT-PRICE-AMT 00001200}
-12.000

This is the display when i give a alphanumeric data

AFLT-PRICE-AMT S999999V999
X'C1C2C3C4C5C6C7C8C0'

here i had given ABCDEFG and it got translated to X'C1C2C3C4C5C6C7C8C0'

I know that a decimal value when gets checked for numeric , the compiler will check for X'0' thru X'9'.

I understand that Since ABCDEFGH gets translated into X'C1C2C3C4C5C6C7C8C0' , the record is does not error out.

Pls explain if my understanding is not correct or if they is a way to check if a signed variable is numeric?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Fri Jan 20, 2006 1:34 pm    Post subject: Reply with quote

Meena_ramanathan,

Quote:

this is the how the field is shown in fileaid. I understand that Since ABCDEFGH gets translated into X'C1C2C3C4C5C6C7C8C0' , the record is does not error out.


Now lets get it clear. how is AFLT-PRICE-AMT defined ? character or numeric? and show us the code for the numeric code check.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Meena_ramanathan
Beginner


Joined: 25 Oct 2005
Posts: 11
Topics: 7

PostPosted: Fri Jan 20, 2006 1:39 pm    Post subject: Reply with quote

The AFLT-PRICE-AMT is defined as S9(6)V999

and the check made is

IF AFLT-PRICE-AMT is numeric.

I'm trying to give some alphanumeric values and i assume the check should capture it , but it is not happening like that.
And i read that

"The numeric class test checks the contents of a data item against a set of
| values that are valid for the particular PICTURE and USAGE of the data
| item. For example, a packed decimal item would be checked for hexadecimal
| values X'0' through X'9' in the digit positions "

so the Hexadeciaml equivalent of the alphabets are checked in "IF numeric" check.

Please correct me if iam wrong.
Back to top
View user's profile Send private message
vst
Beginner


Joined: 23 Jan 2006
Posts: 11
Topics: 0

PostPosted: Tue Jan 24, 2006 4:30 am    Post subject: Reply with quote

Meena_ramanathan,

look at the following funny code Wink

Hopefully it will elucidate the matter.

(I used free hercules/MVS 3.8/COBOL compiler)

Quote:

CB545 V2 LVL78 01MAY72 IBM OS AMERICAN NATIONAL STANDARD COBOL DATE JAN 24,1906


1


00001 IDENTIFICATION DIVISION.
00002 PROGRAM-ID. 'HELLO'.
00003 ENVIRONMENT DIVISION.
00004 CONFIGURATION SECTION.
00005 SOURCE-COMPUTER. IBM-360.
00006 OBJECT-COMPUTER. IBM-360.
00007 SPECIAL-NAMES.
00008 CONSOLE IS CNSL.
00009 DATA DIVISION.
00010 WORKING-STORAGE SECTION.
00011 77 HELLO-CONST PIC X(20) VALUE '=== HELLO, WORLD ==='.
00012 77 AFLT-PRICE-AMT PIC S9(6)V999.
00013 01 AB.
00014 03 A PIC X(04) VALUE IS 'KLMN'.
00015 03 B REDEFINES A PIC S9(04).
00016 PROCEDURE DIVISION.
00017 000-DISPLAY.
00019 DISPLAY HELLO-CONST.
00020 IF B IS NUMERIC DISPLAY B ' IS NUMERIC'.
00021 IF B IS NOT NUMERIC DISPLAY B ' IS NOT NUMERIC'.
00029 MOVE B TO AFLT-PRICE-AMT.
00030 IF AFLT-PRICE-AMT IS NUMERIC
00031 DISPLAY AFLT-PRICE-AMT ' IS NUMERIC'.
00032 IF AFLT-PRICE-AMT IS NOT NUMERIC
00033 DISPLAY AFLT-PRICE-AMT ' IS NOT NUMERIC'.
00034 ADD 0 TO B.
00035 IF B IS NUMERIC DISPLAY B ' IS NUMERIC'.
00036 IF B IS NOT NUMERIC DISPLAY B ' IS NOT NUMERIC'.
00037 STOP RUN.


it produces:

Quote:

=== HELLO, WORLD ===
KLMN IS NOT NUMERIC
00KLM500 IS NOT NUMERIC
234N IS NUMERIC


If you use another version of COBOL compiler it would be interesting to see
your compiler options (NUMCLS/NUMPROC)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group