Skip to Content
avatar image
Former Member

based on arithmetic operation

hello experts,

I have a value with two decimals and one more value with 3 decimals,

when i try to divide the first one by the second one it is giving me wrong result.

ex: 375,000.00 / 15,000.000 = 0.03

How to solve this problem....

plz help me.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Aug 21, 2007 at 07:07 AM

    How many decimals have the variable of the result?

    It's like u have a trunk to 2 decimals.

    DATA: v_result TYPE P DECIMALS 3.

    375,000.00 / 15,000.000 = v_result

    Put your code if it doesn¡t work

    regards

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 21, 2007 at 07:07 AM

    Hello try this

    DATA : a(10) TYPE p DECIMALS 2,

    b(10) TYPE p DECIMALS 3,

    c(10) TYPE p DECIMALS 2.

    a = '375000.00'.

    b = '15000.000'.

    c = a / b .

    WRITE: c.

    it works properly & gives output as 25.00

    reward points if helpful

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 21, 2007 at 07:08 AM

    Hi vinil,

    i do it like this and it works:

    data: p1 type p decimals 2 value 375000.

    data: p2 type p decimals 3 value 15000.

    *

    data: r1 type p decimals 2.

    *

    r1 = p1 / p2. "R1 gets 25,00

    *

    write: r1.

    Can you show the declaration of your fields.

    Regards, Dieter

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      this is my code.......

      SELECT SINGLE * FROM EKPO INTO S_EKPO WHERE EBELN = L_EBELN AND EBELP = L_EBELP.

      DATA: V_RATE TYPE EKPO-NETWR.

      V_RATE = S_EKPO-BRTWR / S_EKPO-MENGE .