Page 1 of 1

Numeric check in Alphanumeric field

PostPosted: Mon Mar 04, 2013 5:21 pm
by ssgan
Hi,

I am having requirement to check whether Alphanumric variable is having numeric value(just numbers) in it.
Ex- VAR 1 defined as X(4).
It can have value as '1234' OR '12ds'
i need to process based on whether it is having number values or alphanum values.
Can anyone help on this?

thanks,
SSgan

Re: Numeric check in Alphanumeric field

PostPosted: Mon Mar 04, 2013 5:33 pm
by BillyBoyo
IF a-far-more-descriptive-name-than-VAR1 NUMERIC
    do some processing for when it is NUMERIC
ELSE
    do some processing for when it is NOT NUMERIC
END-IF

Re: Numeric check in Alphanumeric field

PostPosted: Mon Mar 04, 2013 5:53 pm
by ssgan
Hi,

Thanks for your reply Billy
There are chance that i get input as '12 ' where i should treat this is numeric. Numeric check will skip the process here.

Thanks,
Ssgan

Re: Numeric check in Alphanumeric field

PostPosted: Mon Mar 04, 2013 5:59 pm
by BillyBoyo
Scroll down the screen a bit and have a look at "Check whether a field is Numeric or not", see if that helps.

Re: Numeric check in Alphanumeric field

PostPosted: Mon Mar 04, 2013 6:30 pm
by Robert Sample
Use reference modification (or an array) to check each byte to be spaces or zero through nine (an 88-level might be useful here). If any byte is not one of those 11 eleven characters, it is not numeric. If all bytes are spaces / 0 through 9, then you can use the FUNCTION NUMVAL to convert the PIC X(4) variable to a PIC 9(04) variable and the '12' would be converted as part of that process.

Re: Numeric check in Alphanumeric field

PostPosted: Mon Mar 04, 2013 7:14 pm
by BillyBoyo
Ensure that you deal with "embedded spaces" however it has been defined to you.

>1  2<
> 1 3<
>1 4 <


as well as
>  15<
>16  <
> 17 <


You would need to be certain about how all those should be treated - as numeric, or not, and what output would be required.