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: 

Problem in dividing

0 Kudos
143

hi

I am having a problem while trying to divide a variable with another.

There is an amount field (konv-kbetr) which is a currency type field (length 11 dec 2).

And then there is field for storing exchange rate (like vbkd-kursk) which is decimal type field (lenght 9 dec 5).

When I am trying the divide field1 by field2 then result is coming as zero.

Any idea why it might happen.

Thanx in advance

9 REPLIES 9

former_member188827
Active Contributor
0 Kudos
74

what is data type of result variable?can you tell what values are you getting in both variables?Also,go to program attributes and check if "FIxed point Arithmetic" is checked or not..if not check the check box

0 Kudos
74

data: w_kursk like vbkd-kursk. " This is a decimal type field

Data w_rate like konv-kbetr. " This is a currency type field

Now I am getting the some value in w_rate from some data source.

After that I am getting exchange rate from vbkd into w_kursk var.

Now I want to divide the w_rate variable by w_kursk and store the value into the same variable i.e. w_rate.

Sample code is given below.

select single kursk
          into w_kursk
          from vbkd
          where vbeln = komp-aubel.
 if sy-subrc = 0.
 w_rate = w_rate / w_kursk.
 endif.

0 Kudos
74

what is data type of w_rate?Is fixed point arithmetic checked in program attributes?

0 Kudos
74

The variable w_rate is currency type field.

It was declared as w_rate like konv-kbetr.

The prg which i am using is ALT Condition type routine

(Created from VOFM->formulas->condition value).

Here in the prg attribute section fixed point arithmetic box not appearing.

0 Kudos
74

in such cases its better that u create a function and carryout computations inside it.The main program of function group will have fixed point arithmetic checked and these problems will not occur there.

0 Kudos
74

Like Mr. Abapuser told you, you can now:

1. Change your program to fixed point arithmetic. Tho i wouldnt propose that since you do not know what other calculation operation are done in that program and how they will suffer.

2. make yourself a own function module for which you can switch on fixed point arithmetic, and do your calculation in there.

0 Kudos
74

Thanx for your valuable suggestion.

It was nicely done...................

Former Member
0 Kudos
74

well, your destination variable has just two decimals i guess.

So once your value is under 0,0050 which would be rounded to 0,01 you get 0.

Check fixed point arithmetik, you have some decimals problem here giving you values of 0,0006 and such.

Former Member
0 Kudos
74

In the attributes of the program, make sure that fixed point arithmetic is checked.

Rob