Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

comparing character value to numeric

mohan_subramania
Explorer
0 Likes
1,229

i want to compare one character field to numeric,

i got one field from some custom developed fm the field having the p_value

is of type c(30) , i want to compare this value to numeric 50000 if i use the following code it

does not give the correct value. please help

if p_value GE '50000'

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,064

data: var1(30) type n.

var1 = p_value.

if var1 GE 50000.

....

3 REPLIES 3
Read only

Former Member
0 Likes
1,064

Hi,

data:

w_int type i,

w_char(13) type c.

w_int = w_char.

if w_int ge 50000.

ur code

endif.

Read only

Former Member
0 Likes
1,065

data: var1(30) type n.

var1 = p_value.

if var1 GE 50000.

....

Read only

Former Member
0 Likes
1,064

when you compare character value to numeric it compared from left to right not considering the length of both the variables.

Which means you will have to something like:

if p_value GE '000000000000000000000000050000'

this should give you the correct result.