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: 

remainder and quotient

kiran_k8
Active Contributor
0 Kudos

Hi Folks,

a = 4

b = 2

c = a/b

c = 2.

d = remainder.

e = quotient.

Now I have to get the remainder of this too and store it in a variable.For the above caluculation remainder is 0 and quotient is 2.How to get these two values.

K.Kiran.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

DIV - integer division

MOD - remainder for integer division

<b>reward points if useful.</b>

regards,

Vinod Samuel.

5 REPLIES 5

Former Member
0 Kudos

Hi kiran,

There are lots of SAP keywords available.

Check below keywords.

Function func Return value

abs Absolute value of the argument arg

sign Plus/minus sign of the argument arg: -1, if the value of arg is negative; 0 if the value of arg is 0; 1 if the value of arg is positive.

ceil Smallest integer number that is not smaller than the value of the argument arg.

floor Largest integer number that is not larger than the value of the argument arg.

trunc Value of the integer part of the argument arg

frac Value of the decimal places of the argument arg

You may check which one suits you.

Regards,

Atish

Former Member
0 Kudos

Hi,

DIV - integer division

MOD - remainder for integer division

<b>reward points if useful.</b>

regards,

Vinod Samuel.

Former Member
0 Kudos

Hi,

Check this out -

data: l_a type i, l_b type i.

l_a = 20.

l_b = l_a div 6.

write:/ l_b. Output is 3

l_b = l_a mod 6.

write:/ l_b. Output is 2

Hope this helps.

ashish

Former Member
0 Kudos

HI

Check this eaxample

DATA: pack TYPE p DECIMALS 4,

n TYPE f VALUE '+5.2',

m TYPE f VALUE '+1.1'.

pack = n / m.

WRITE pack.

pack = n DIV m.

WRITE / pack.

pack = n MOD m.

WRITE / pack.

Thanks,

Praveen

Former Member
0 Kudos

<b>DATA: num1 type i,

num2 type i,

res type i,

res1 type i.

num1 = 4.

num2 = 2.

res = num1 mod num2. " To get remainder

res1 = num1 / num2. " To get quotient .

write:/ res, res1.

Regards

SANTOSH K.</b>