Skip to Content

Rounding-off Currency fields.

Hi,

Can someone tell me how to round-off value of currency field.

If fraction <= 0.49 it should be rounded-off to 0.00

If fraction >= 0.50 it should be rounded-off to 1.00

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Oct 14, 2005 at 04:06 PM

    Try this...

    
    report zrich_0002 .
    
    
    data: curr1 type p decimals 2 value '.49',
          dec type p decimals 2 .
    
    
    dec = frac( curr1 ).
    if dec <= '.49'.
      curr1 = floor( curr1 ).
    else.
      curr1 = ceil( curr1 ).
    endif.
    
    
    check sy-subrc  = 0.
    
    

    Regards,

    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 14, 2005 at 08:05 PM

    Hi, you have the Function Module ROUND too,

    here a litle example ( the paremeter sign = 'X' set how the number will be rounded )

    DATA l_input TYPE p DECIMALS 5.

    break-point.

    l_input = '0.499'.

    CALL FUNCTION 'ROUND'

    EXPORTING

    decimals = 0

    input = l_input

    sign = 'X'

    IMPORTING

    output = l_input

    EXCEPTIONS

    input_invalid = 1

    overflow = 2

    type_invalid = 3

    OTHERS = 4.

    l_input = '0.500'.

    CALL FUNCTION 'ROUND'

    EXPORTING

    decimals = 0

    input = l_input

    sign = 'X'

    IMPORTING

    output = l_input

    EXCEPTIONS

    input_invalid = 1

    overflow = 2

    type_invalid = 3

    OTHERS = 4.

    Saludos

    Daniel

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 14, 2005 at 04:06 PM

    parameter p(4) type P decimals 2.

    data wa(4) type P decimals 0.

    data wa1(4) type P decimals 2.

    wa = p .

    wa1 = wa .

    write wa1.

    Cheers.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 14, 2005 at 04:07 PM

    Just move it to a integer field.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.