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

Problem in Division

Mohamed_Mukhtar
Active Contributor
0 Likes
2,489

Hi,

I'm facing an issue while division . I have piece of code which is working fine when it is run in a separate program and the same code included into a program its not able to divide.


This code is workign fine separately     
DATA: V_ZAR TYPE NETWR_AK,
      V_RATE TYPE KOMVD-KWERT value '4918.88',
      lv_rate type kursk value '14.07301-',
      lv_char(12).
break-point.
move lv_rate to lv_char.
if lv_char ca '-'.
v_zar = ( v_rate DIV lv_rate ) * -1.
endif.
break-point.

And please check this code


The problem is with this code
DATA: V_ZAR TYPE NETWR_AK,           " ZAR Currency Amount
            V_RATE TYPE KURSK.             " Exchange Rate  
if lv_rate ca '-'.
              V_ZAR =  ( KOMVD-KWERT DIV V_RATE ) * C_1.
            else.
              V_ZAR = KOMVD-KWERT * V_RATE.
            endif.
After division V_zar  holds 0.00

Thanks & Regards

- Always Learner

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,932

Hi

what's the value of C_1??

you are sure that you are not multiply per 0?

or that all the value al valorized'??

regards

Marco

12 REPLIES 12
Read only

Former Member
0 Likes
1,933

Hi

what's the value of C_1??

you are sure that you are not multiply per 0?

or that all the value al valorized'??

regards

Marco

Read only

0 Likes
1,932

Hi Menegazzo,

Thanks for your reply, C_1 is a constant.

constants : c_1 type i value '-1'.

Thanks

Read only

0 Likes
1,932

Hi

have you tried if with


V_ZAR = KOMVD-KWERT * V_RATE.

V_ZAR is different of 0.00?

regards

marco

Read only

0 Likes
1,932

Thanks Marco,

V_ZAR = KOMVD-KWERT * V_RATE.

V_ZAR is getting correct result in multiplication. The problem is in division. I

Read only

0 Likes
1,932

Hi

this issue is very strange because the data types are equal in both the code..

the only think can be that the values are not correct

try to replace DIV with /.....

regards

Marco

Read only

0 Likes
1,932

I replaced '/' with DIV because it was not working. Yes its a strange problem thats why i posted this thread, thought like i may get some ideas to overcome this issue. Anyways thanks Marco for your time spent on my issue.

Read only

0 Likes
1,932

How your nik say we have always to learn

Read only

0 Likes
1,932

Hi...

i have understand the problem.

The DIV not work because it cut the decimal number....so if the result is 0,45 you will see 0.00.... else if is 1,45 you will see 1.

with / you not resize the number for that if you have 0,45 you will se 0,45 and so on.

replace the value in you working code


DATA: V_ZAR TYPE NETWR_AK,
      V_RATE TYPE KOMVD-KWERT value '1',
      lv_rate type kursk value '2-',
      lv_char(12).
break-point.
move lv_rate to lv_char.
if lv_char ca '-'.
v_zar = ( v_rate DIV lv_rate ) * -1.
endif.
break-point.

v_zar will be 0.00 and not 0.5.

regards

Marco

Edited by: Menegazzo Marco on May 25, 2010 12:07 PM

Read only

0 Likes
1,932

Hi,

Select the checkbox of your program attributes of FIXED POINT ARTHMETIC

in SE38 Select the ATTRIBUTES radion button and click on CHANGE button then select this CHEK BOX

This would resolve your issue

Cheerz

Ram

Read only

0 Likes
1,932

Thanks Ram , it worked like as expected.

Read only

Former Member
0 Likes
1,932

null

Edited by: luigi la motta on May 25, 2010 12:10 PM

Edited by: luigi la motta on May 25, 2010 12:10 PM

Read only

Former Member
0 Likes
1,932

Hi ,

It may be because you are validating lv_rate not the v_rate variable , just check it out your code .

The problem is with this code

DATA: V_ZAR TYPE NETWR_AK, " ZAR Currency Amount

V_RATE TYPE KURSK. " Exchange Rate

if lv_rate ca '-'.

V_ZAR = ( KOMVD-KWERT DIV V_RATE ) * C_1.

else.

V_ZAR = KOMVD-KWERT * V_RATE.

endif.

After division V_zar holds 0.00

Best Regards,

Prasad