Quantcast
Channel: IBM Mainframe Computers Forums
Viewing all articles
Browse latest Browse all 8500

COBOL Programming :: Validate if a Value from the file is numeric

$
0
0
Author: balacsv2
Subject: Validate if a Value from the file is numeric
Posted: Mon Jun 19, 2017 11:52 pm (GMT 5.5)

I am reading a comma delimited file which comes from another vendor using unstring.I have a field from the file which could have values with the decimal point for ex.95.6 .I am receiving the field from the input file with the declaration

05 WS-PERCENT PIC X(06) JUST RIGHT

I need to check if WS-PERCENT which comes from the vendor is numeric.After receiving the field as mentioned above with JUSTIFIED RIGHT i did an inspect to make sure that i remove the leading spaces

code:
INSPECT WS-PERCENT REPLACING LEADING SPACES BY ZEROES
DISPLAY "WS-PERCENT" WS-PERCENT
IF WS-PERCENT IS NUMERIC
Do some statements
else
set Error swtich to true
END-IF

After the inspect it displayed
DISPLAY "WS-PERCENT" 0099.5

but the IF WS-PERCENT IS NUMERIC check is failing.Can someone correct me what is it that i am doing wrong here?? My ultimate aim is to make sure that the percentage value has valid numeric ,any other ideas are welcome
_________________
Bala V


Viewing all articles
Browse latest Browse all 8500

Trending Articles