Page 1 of 1

compare numeric and alphanumeric values ?

PostPosted: Mon Jan 11, 2010 10:31 am
by mathew28
I have a numeric value var1 9(7) = 0334454
and another alphanumeric value var2 x(7) = 334454. I need to compare var1 = var2. Though both the values are same, the condn if var1 == var2 fails. To make it work, i moved the alphanumeric var2 to a temp numeric variable var3 9(7) (MOVE var2 TO var3). The value is getting moved as 3344540. So, still 0334454 is not equal to 3344540.

Is there a solution to remove the leading zeros in var1 ? OR Is there a solution to right justify the value in the temp variable var3 ? Please help....

Re: compare numeric and alphanumeric values ?

PostPosted: Mon Jan 11, 2010 11:09 am
by dick scherrer
Hello,

If you know the value in var2 will always be valid, you could use NUMVAL for the move to the temp numeric.

http://publibz.boulder.ibm.com/cgi-bin/ ... r40/7.1.32

If the value in var2 is ever non-numeric, it will abend.

Re: compare numeric and alphanumeric values ?

PostPosted: Mon Jan 11, 2010 2:59 pm
by mathew28
Thanks very much dick for the timely help !!

Re: compare numeric and alphanumeric values ?

PostPosted: Tue Jan 12, 2010 12:24 am
by dick scherrer
You're welcome - good luck :)

d