Skip to Content
author's profile photo Former Member
Former Member

1.232 to 1.24

Hi

if the value of a is 1.232 then i want 1.24

a = 1.23 i want 1.23

a = 1.236 i want 1.24

Thanks,

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Best Answer
    Posted on Dec 23, 2008 at 03:26 AM
    data : l_val type p decimals 2,
             l_val2 type p decimals 3.
    
    
    l_val2 = 1.236.
    move l_val2 to l_val.
    
    write :/ l_val.

    Best regards,

    Prashant

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 03:30 AM

    hi,you can declare two variables like

    data : v_val type p decimals 2,

    v_val2 type p decimals 3.

    and then assign values to v_val and then move it to value 2.

    thanks

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 03:47 AM

    this not possible by using key word but you can do manupulations,

    usevally round keyword will do if 0.126 -


    > 0.13, 0.123----


    > 0.12

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 03:50 AM

    Hi,

    Declare on more variable with two decimal places & pass the value.

    da: temp type p decimals 2.

    Thanks,

    Krishna..

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 04:14 AM

    Use FM ROUND

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 05:59 AM

    Hi,

    Use the following code:

    DATA: num1 TYPE p DECIMALS 3 VALUE '1.232',
               num2 TYPE p DECIMALS 2.
    
    CALL FUNCTION 'ROUND'
      EXPORTING
        decimals      = 2
        input         = num1
        sign          = '+'
      IMPORTING
        output        = num2
      EXCEPTIONS
        input_invalid = 1
        overflow      = 2
        type_invalid  = 3
        OTHERS        = 4.
        
    IF sy-subrc EQ 0.
      WRITE:/ num1, num2.
    ENDIF.

    This will work for all the cases:

    num1 = 1.232 then num2 = 1.24

    num1 = 1.23 then num2 = 1.23

    num1 = 1.236 then num2 = 1.24

    Regards,

    Lavanya

    Edited by: Lavanya Gourisetty on Dec 23, 2008 9:49 AM

    Edited by: Lavanya Gourisetty on Dec 23, 2008 10:23 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 10:11 AM

    Hi,

    Try like this:

    WRITE A ROUND 2.

    Regards,

    Bhaskar

    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.