Application Development 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: 

comparing values..

Former Member
0 Kudos

hi,

i have 2 variables, one of type char 30 and another char 10. One has a value 0.220 and another has 0.22.

When I compare these two values, it seems it fails.

If var = var2.

endif.

Is there a way where i can convert one of these into a format of the other just before comparing ? i cannot change the data types of these variables now as it will affect many parts of the related programs. I just need to typecast them to same width for comparison purpose only. any tips ?

thks

1 ACCEPTED SOLUTION

JozsefSzikszai
Active Contributor
0 Kudos

hi,

if these character type variables always contain numbers with decimals, than I would suggest to define variables type p with some decimals. Than move the values to these p variables and then you can compare.

hope this helps

ec

2 REPLIES 2

JozsefSzikszai
Active Contributor
0 Kudos

hi,

if these character type variables always contain numbers with decimals, than I would suggest to define variables type p with some decimals. Than move the values to these p variables and then you can compare.

hope this helps

ec

Former Member
0 Kudos

Hi,

I am not sure , You can try this way-

data:w_char1(30) type c value '0.220',

w_char2(10) type c value '0.22'.

if w_char1 CS w_char2.

write:'OK'.

endif.