Check whether a field is Numeric or not

Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Re: Check whether a field is Numeric or not

Postby BillyBoyo » Thu Aug 30, 2012 8:02 pm

I think the values for 2 and 3 are what they should be, but, (and you can see it is a big one) I now suspect you are right about the whole thing.

Nik, if you do it without the other stuff (the REVERSE and LEADING SPACE, as set out previously) then you will be letting bad data through.

You have ALL SPACE for your INSPECT, where you need LEADING (after the REVERSE, because "trailing space" is OK but leading or embedded is no, but you can't put TRAILING on the INSPECT).


Only the 9 is valid, yet with your INSPECT all would be accepted.
Global moderator
Posts: 3733
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 254 times

Re: Re: Check whether a field is Numeric or not


Re: Check whether a field is Numeric or not

Postby Nik22Dec » Fri Aug 31, 2012 5:24 pm

Hi All,

Apologies! I should have been clearer in presenting my peculiar requirement. In my case, leading spaces are also acceptable. I move the input value to the output field by using NUMVAL. So, that takes care of it.

The inspect is just to enure that we don't pass a non-numeric(plain spaces/alphabetic/alphanumeric) value to NUMVAL.I filter out all spaces before the INSPECT. I finally check the copied & meshed value with IS NUMERIC which tells me if the value entered is a valid one or not.

I most sincerely appreciate your concern & willingness to help me out with this. I feel lucky to be able to reach out to all of you in my time of crisis. Thank you All!!
User avatar
Posts: 68
Joined: Mon Dec 26, 2011 6:38 pm
Has thanked: 2 times
Been thanked: 0 time


Return to IBM Cobol


  • Related topics
    Last post