FM to Round decimal place

Hi Gurus,
I want to reduce the number of decimal place by rounding off 2 decimal place.
I am using 'HR_NZ_ROUNDING_DECIMALS' function module but its not working,
kindly do the needful.
Regards,
Maithili

Hi,
Use Type cast method instead of finding FM.
DATA : i type p decimals 4 VALUE '57846.5379'.
DATA : j type p decimals 2.
j = i.
Write : / i.
Write : / j.
Regards,
Velmurugan B

Similar Messages

  • Having some trouble rounding decimal place

    Hello all,
    I am having some issues rounding a decimal in my code. My program is running and doing what I would like otherwise. Here is what I have so far:
    public class MortCalc2
         public static void main(String [] args)
              //Declare and initialize three variables
              double numloanamt = 200000.00; //loan amount of 200k
              double numinterest = 0.0575;  //interest rate of 5.75%
              int numtermyrs = 30;  //term of 30 years
              int numtermmths = 360;  //term of 360 months
              double numwholeamt = 545000.00;  //loan amount + interest
              double numpayment = 0;  //monthly payment
              numpayment = numwholeamt/numtermmths;  //payment equals loan amount plus interest divided by the total term in months
              System.out.println("Your monthly payment is $" + numpayment);
    }I am getting the results I want with the calculation except they are coming out as 1513.888888888889. I would like to see 1513.89. Can someone point me in the right direction. Thank you in advance for any help you can provide.
    Thanks,
    Seawall

    Hi, sorry for the first post.
    this works okay.
    import java.math.*;
    public class MortCalc2
         public static void main(String [] args){
    are and initialize three variables
    double numloanamt = 200000.00; //loan amount of
    of 200k
    double numinterest = 0.0575;  //interest rate of
    of 5.75%
              int numtermyrs = 30;  //term of 30 years
              int numtermmths = 360;  //term of 360 months
    double numwholeamt = 545000.00;  //loan amount +
    + interest
              double numpayment = 0;  //monthly paymen
    numpayment = numwholeamt/numtermmths;  //payment
    t equals loan amount plus interest divided by the
    total term in months
    numpayment =
    Math.round(numpayment*100.0) / 100.0;
    System.out.println("Your monthly payment is $" +
    + numpayment);
    Thats right, use an Irish screwdriver (a hammer) instead of the correct solution as posted by djmd02 in repsonse #3.

  • Decimal places

    Decimal places are defined in the general settings.
    They are currently set to 2 decimal places.
    We have the required for 5 customers to be priced and invoiced at 3 decimal places.
    Is this possible?

    Hi Lisa,
    Please also notice the following information
    When you tick the option: Rounding By: Currency from the Administration-System Initialisation-Document Setting window.
    You could assign different rounding /decimal place per different currency
    ( Administration-Definition-Financial-Define Currencies)
    Hope this can be helpful.
    Best Regards
    Helen Sun

  • Rounding up decimal places

    Hi,can anyone please tell me how to round up a double type value to 6 decimal places.
    Thank You!

    You should be able to adapt this solution I posted last week:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=412237
    Changing the int's to double's will probably work fine.
    Cheers,
    Radish21

  • Rounding up to a particular decimal place

    Hi,
    I'm bringing a field into my report that uses up to eight decimal places.  I'm tasked with rounding things up to the fifth decimal.  Rather than rounding when the number is five or higher, it should always round up if it is above one.
    So for example:
    2.03827893 rounds up to 2.03828000
    11.40032180 rounds up to 11.40033000
    Any ideas on the best approach for achieving this within a Crystal formula?
    Any help would be greatly appreciated.
    Thank you.

    Hi Bob,
    Right click on the field and select "Format Field"
    In "Number" tab, select "Custom Style" then click on "Customize"
    In the Roundig box you can select the Rounding type.
    --Praveen G

  • Rounding To Nearest Decimal Place

    Hey Flash Family,
    I am getting the correct output i want but is also giving me
    like 8 numbers after the decimal place...all i want is the numbers
    rounded to the nearest cent meaning only 2 numbers to the right of
    the decimal point....what do i need to add to the current code to
    correct this issue.
    Thanks N Advance

    attach that code to the first frame of your main timeline.
    then anytime you need to change the format of a number like
    _root.how.ROIM.val_tcost use:
    _root.return2DecPlaces(_root.how.ROIM.val_tcost);

  • Rounding a quantity field to one decimal place. PLEASE URGENT

    I have a quantity field with three decimal places. I have to print this field with only one decimal place. This is in a smartform.
    suppose: qty = 45.678
    I want it to be printed as 45.7
    Thanks in advance.

    Hi Riki,
    I think you can use Function Module ROUND to round off the value...
    REPORT ZTEST_SHAIL4 .
    data: out type p decimals 1,
    inp type f.
    inp = '45.678'.
    CALL FUNCTION 'ROUND'
    EXPORTING
    DECIMALS =
    input = inp
    SIGN = ' '
    IMPORTING
    OUTPUT = out
    EXCEPTIONS
    INPUT_INVALID = 1
    OVERFLOW = 2
    TYPE_INVALID = 3
    OTHERS = 4
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Now use the variable 'out' to display the rounded off value...
    Regards,
    SP.

  • Rounding to two decimal places in BPC/NW

    Hello,
    I am dealing with the task to round values to two decimal places. I have found some discussions in BPC-MS where the statement ROUND should work in logic. Unfortunately I am not able to make it work in the NW version.
    Isn't there also a parameter in the appset or application administration which would cut the numbers only to two decimal places (this task would be also a possible solution for us).
    Thanks for any help
    Jan

    Hello Pravin,
    the second import worked fine. I realized that the class has changed to ZCL_BPC_SL_ROUND.
    I debugged the class and noticed that the parameter it_cv is not filled at all. Therefore the program ends before starting the rounding procedure. Here is the part of the code:
    Take CV into account
      clear l_success.
      loop at it_cv into ls_cv.
        clear l_val_string.
        loop at ls_cv-member into l_member.
          if sy-tabix eq 1.
            l_val_string = l_member.
          else.
            concatenate l_val_string l_member into l_val_string separated by ','.
          endif.
        endloop.
        if l_val_string ne space.
          l_success = add_dim_restriction( i_param = l_val_string i_dimension = ls_cv-dimension i_clear = abap_true ).
          if l_success eq abap_false.
            concatenate 'Failed to successfully add Dimension' ls_cv-dimension into l_log_msg
            separated by space.
            cl_ujk_logger=>log( l_log_msg ).
            cl_ujk_logger=>log( 'Exiting Round Method' ).
            cl_ujk_logger=>empty_line(  ).
            raise exception type cx_uj_custom_logic
              exporting messages = et_message.
            exit.
          endif.
        endif.
      endloop.
      if l_success eq abap_false. exit. endif. - here the program exits and therefore doesn't do any rounding.
    If I comment this part the system rounds correctly but runs on all records in the cube which degrades performance a lot.
    Could you please advice further if it is possible to restrict the data region only to the submitted data?
    Best regards
    Jan

  • Rounding to decimal places in Captivate 6

    I need some assistance with rounding to 2 decimal places in Captivate 6. Can this be done without scripting?
    Vince

    Rod or anyone
    Would you be able to direct me to where I would be able to find the Javascript for rounding a variable to 2 numbers in Captivate 6?
    Vince

  • Rounding Rule upto 3 Decimal Places in Tax Condition(SABRIX)

    Hi,
    We are Using SABRIX for Tax determination and need to round up Condition Type XR1- XR6 to round upto 3 Decimal Places.
    Do we need to To Change ALT Calc Type- 301306or Alt Cond Base Value -- 16  or have to change Currency  decimal Places in transaction OY04/OY03.
    Kindly Suggest.
    Thanks
    Amit

    Hi,
    Tax % for customer is decided in SABRIX, Where does TaX calculated?? In SABRIX or in SAP.
    Thanks
    Amit
    Edited by: AMIT GUPTA on Mar 31, 2010 10:54 AM

  • Rounding to 2 decimal places in Derived column transform editor

    I want to replace the contents of a value column with itself but rounded to 2 decimal places.
    The current column is a double and I have tried to perform this using the following expression but it fails to work.
    Code Snippet
    Round(cc_vl,2)
    How should I achieve this?

    I’ll take a guess here but you started with this –
    123.45678
    Got this –
    123.45000
    Wanted this –
    123.45
    So the 123.45000 is absolutely correct, the value has been rounded to 2 digits. A double however has a scale greater than 2, and you only wanted two digits after the point because you were concerned about how the value looked rather than the actual value. This is certainly not a bug. It is how you format the data for display.
    Your solution is the way to do this, either on the Derived Column or Data Conversion Transformation. You got it in the end, the replace versus new, because you cannot change the type of a column. You may convert the value, but the storage type of the column means it will implicitly revert to the base column type when you put it back, albeit with a value that has been rounded.
    Does that explain it?

  • Rounding Doubles to Two Decimal Places

    Hi All,
    I've searched the archive and found a few different posts regarding restricting the number of decimal places in doubles. However they all suggest different methods, BigDecimal, NumberFormat etc.
    Which is the simplest method of rounding a number say 10.023445656 to 10.02?
    I tried using the java.text.NumberFormat but this turns the double into a string and I need the end result to be a double.
    Thanks

    Hi All,
    I've searched the archive and found a few different
    posts regarding restricting the number of decimal
    places in doubles. However they all suggest different
    methods, BigDecimal, NumberFormat etc.
    Which is the simplest method of rounding a number say
    10.023445656 to 10.02?
    I tried using the java.text.NumberFormat but this
    turns the double into a string and I need the end
    result to be a double.
    ThanksI ahve a small code that can do the work for u:
    import java.text.*;
    double format(double val, int dec){
        double multiple=Math.pow(10,dec);
        val=Math.round(val*multiple)/multiple;
        DecimalFormat df=new DecimalFormat("0.00");
        String format=df.format(val);
       double dval=Double.parseDouble(format);
       return dval;
    }//end of functionHope that helps!

  • How to round decimal point to two places

    Hi all, I have been tasked with creating a custom "calculator" for a client that uses a specific equation. The client inputs data into two Input Text fields and the result shows up in a dynamic text field. Is there any way I can limit the number of decimal places to two? Here is my code (which works, except for the decimal issue):
    function onCalculate()
    one = Number(number_one);
    two = Number(number_two);
    result_1 = ((one / 4) * (65 / (1 - 0.25))) + ((two / 0.5) * (65 / (1 - 0.25)));
    Thanks in advance!!!!

    What will often be done is the result is first multiplied by 100, then rounded to an integer, then divided by 100.  So picking up from your last line where you calcvulate the result_1 value...
    result_1 = Math.round(result_1*100)/100;

  • Rounding to 2 decimal place

    Hi,
    I am trying to round the decimal place of number 0.105 as .11.
    But it only rond up to 0.1 not 0.11.
    I don't understand why it doesn't round to 0.11.
    Can any one explain to me ?
    My code :
    import java.util.*;
    import java.text.*;
    import java.math.*;
    public class TestFile {
    public double number = .105;
    public static void main(String[] args) {
    TestFile test = new TestFile();
    DecimalFormat aFormat = new DecimalFormat("#.##");
    int decimalPlace = 2;
    double num = .105;
    BigDecimal bd = new BigDecimal(num);
    bd = bd.setScale(decimalPlace,BigDecimal.ROUND_HALF_UP);
    //DecimalFormat aFormat=new DecimalFormat("###.00");
    String formattedString = aFormat.format(test.number);//format the String entered
    System.out.println("formatted string: " + formattedString);
    System.out.println("big decimal " +bd.doubleValue());
    double formattedDouble = Double.parseDouble(formattedString);//convert to a double
    System.out.println("back to a double: " + formattedDouble);
    What should I do to round 0.11 ?
    Thanks,
    njan.

    BigDecimal bd = new BigDecimal(num);Change this line to
    BigDecimal bd = new BigDecimal(Double.toString(num));Read the notes in the API for BigDecimal constructor that accepts double.
    http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#BigDecimal(double)
    The results of this constructor can be somewhat unpredictable...

  • Rounding to a decimal place

    like, right now i have this huge equation;
    double heatIndex8 = (-42.379) + (2.04901523 * birmingTemp[7]) + (10.14333127 * birmingHum[7]) - (0.22475541 * (birmingTemp[7] * birmingHum[7])) -
                             (6.83783 * Math.pow(10, -3) * Math.pow(birmingTemp[7], 2)) - (5.481717 * Math.pow(10, -2) * Math.pow(birmingHum[7], 2)) +
                             (1.22874 * Math.pow(10, -3) * Math.pow(birmingTemp[7], 2) * birmingHum[7]) + (8.5282 * Math.pow(10, -4) * birmingTemp[7] * Math.pow(birmingHum[7], 2))
                             - (1.99 * Math.pow(10, -6) * Math.pow(birmingTemp[7], 2) * Math.pow(birmingHum[7], 2))and it prints out an insane amount of decimal places...
    how can I tell the code to round(heatIndex8) to the tens place?

    paulcw wrote:
    Use a java.text.DecimalFormat, or one of the printf methods that are now all over the place. (Well, String and java.io.PrintWriter and PrintStream, in particular).
    By the way the size of the equation doesn't have a lot to do with it.
    Edited by: paulcw on Feb 2, 2008 1:23 PMI know it doesn't, but I just really hate it.
    decimal format you say? I'll go check that.

Maybe you are looking for