Rounding off to nearest value with formatNumber

Can I use the formatNumber tag to round my numeric value to the nearest value?
Like if it's 15.7 I would like to display 16
And if it's 15.2, I would like to display 15
I could successfully truncate by giving a patteren but Im not sure if I can round it off.
Regards,
Leena

Yes you can - the following works on JSTL 1.1 / Tomcat 5.5 :
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head><title></title></head>
<body>
Test Auto Rounding of 16.8 :
<fmt:formatNumber value="16.88" pattern="##"/>
<br/><br/>
Test Auto Rounding of 16.2 :
<fmt:formatNumber value="16.22" pattern="##"/>
</body>
</html>Message was edited by:
appy77

Similar Messages

  • Rounding off net weight value.

    Hi experts,
    I want to round off the quantity value to the next integer value.
    I am using the FM 'J_1I6_ROUND_TO_NEAREST_AMT' as follows...
    call function 'J_1I6_ROUND_TO_NEAREST_AMT'
    exporting
       i_amount = gross_weight
       i_amount1 = net_weight
    importing
       e_amount = gross_weight
       e_amount1 = net_weight.
    i want to round off the gross weight and net weight values.
    In Global definitions, these are given as of type VEKP-BRGEW. The field BRGEW is of datatype QUAN (length - 15 and decimal -3 )
    But when i tried executing i am getting dump .... saying
    "The function module interface allows you to specify only
    fields of a particular type under "I_AMOUNT".
    The field "GROSS_WEIGHT" specified here is a different field type"
    Please help me solve this and please let me know how to round off these fields.
    Regards
    Ammu

    Hi,
    the both fm parameters you fill have a currency data element of length 13, while you pass a quantity data element of length 15.
    You can't use this fm for your fields.
    Regards,
    Klaus

  • Problem in Routine after rounding off the condition value

    Dear all,
          I have attached the routine for rounding off value for condition value for T.Code va02. Routine is working fine but the problem is after the execution of routine it goes in some standard program LV61AA55 where again the rounded value gets changed . Maximum points will be allocated ..
    Thanks anr Regards

    FORM FRM_KONDI_WERT_925.
    *{   INSERT         D01K911062                                        2
    data : wa_xkomv like xkomv,
            v_kwert like xkomv-kwert,
           W_INDEX  TYPE SY-TABIX.
    read table xkomv into wa_xkomv with key kschl = 'JIN6'.
    W_INDEX = SY-TABIX.
    v_kwert = 1 * wa_xkomv-kwert / 100.
      V_KWERT = WA_XKOMV-KWERT.
    read table xkomv with key kschl = 'JHSC'.
    CALL FUNCTION 'J_1I6_ROUND_TO_NEAREST_AMT'
       EXPORTING
         I_AMOUNT                 = v_kwert
       I_AMOUNT1                =
       I_AMOUNT2                =
       I_AMOUNT3                =
       I_AMOUNT4                =
       I_AMOUNT5                =
       I_EXADDTAX1_AMOUNT       =
       I_EXADDTAX2_AMOUNT       =
       I_EXADDTAX3_AMOUNT       =
      IMPORTING
        E_AMOUNT                 = v_kwert
       E_AMOUNT1                =
       E_AMOUNT2                =
       E_AMOUNT3                =
       E_AMOUNT4                =
       E_AMOUNT5                =
       E_EXADDTAX1_AMOUNT       =
       E_EXADDTAX2_AMOUNT       =
       E_EXADDTAX3_AMOUNT       =
    xkomv-kwert = v_kwert.
    xkwert = v_kwert.
    modify xkomv INDEX W_INDEX transporting kwert.
    *}   INSERT
    ENDFORM.

  • SQL for rounding to the nearest value

    Hi All,
    My Oracle DB version is 10g Release2 and also 11gR1
    I have data like below, I need to write a SQL for the below requirement.
    ID   RANGE_LOW                RANGE_HIGH
    1      50                    55             
    2      55                    60
    3      60                    63 
    4      63                    77 
    5      77                    84   The requirement is like I need to check a value between the above range low and high then round it to the nearest value.
    Say, for example if I have 68 then the value is rounded to 63 else if 74 then 77 else if its in the middle of two values (70) then rounded to the highest value, here its 77.
    Please advice.

    Ashu_Neo wrote:
    hi Purvesh,
    I think , you didn't check it properly with requirement of posting. Your query needs to be changed a bit. Please verify againYes, I probably missed or overlooked the last line.
    Here is the updated solution then:
    with data as
      select 1 id, 50 low, 55 high from dual union all
      select 2, 55, 60 from dual union all
      select 3, 60, 63 from dual union all
      select 4, 63, 77 from dual union all
      select 5, 77, 84 from dual 
    chk_val as
      select &val val from dual
    select id, low, high,
           val input_value,
           case
            when val < (low + high)/2
              then low
            else
              high
           end round_value
      from data, chk_val
    where val between low and high;
    ID                     LOW                    HIGH                   INPUT_VALUE            ROUND_VALUE           
    4                      63                     77                     70                     77

  • Rounding off to nearest whole number without condition

    hi,
    i want to round a real number to an integer value,,wihout any conditions like
    10.01 should be 11
    10.1 should be 11 and like that
    is it posible to do it?
    thanks in advance.
    amit

    It doesn't look like you are trying to round to the nearest whole number here. It looks like you are trying to find the smallest integer value that is greater than or equal to the real number. If so, you would want to use the CEIL function (i.e.
      1  SELECT CEIL(10.01)
      2*   FROM dual
    SCOTT @ hp92 Local> /
    CEIL(10.01)
             11Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Rounding Off to lower value!

    Dear Experts,
    Currently am calculating some values, and it returns me the results as such:
    If the calculated value is 6.85714, then by default the output value in my integer type variable is 7.
    Now, whenever the output results in 6.xxx, even if it is 6.9999 then i want it to round off to 6.
    How is it possible?
    Please advice!
    Regards,
    Sundar.

    Hi
    Handle it like this,,,
    CLEAR : l_f_kbetr4 , l_f_kbetr5 .
    l_f_kbetr4 =   l_F_kbetr1 - l_f_kbetr3 .
    CHECK      =   FRAC( l_f_kbetr4 ) .
    IF CHECK GE '0.50' .
      l_f_kbetr4  = CEIL( l_f_kbetr4 ) .
    ELSE .
      l_f_kbetr4  = FLOOR( l_f_kbetr4 ) .
    ENDIF.
    l_f_kbetr5        =   l_f_kbetr4 .
    Hope it helps.
    Praveen

  • How to avoid rounding off large Double values?

    For converting from String to Double, consider a piece of code as below:
    String str = "999999999999999.99999";
    Double d = Double.valueOf( str );In this case, d will contain the value 1E15 and not 999999999999999.99999.
    Is there any way by which we can avoid this rounding off?
    TIA,
    Ninad.

    > String str = "999999999999999.99999";Note that you have a total of 20 decimal digits here.
    A double only has 53 bits to represent the mantissa
    so it can only accurately represent about 16 decimal digits.

  • Rounding off Issue (Net Value not equal to Net Price * quantity)

    Dear Gurus,
    Here is an interesting issue.The default calculation done in the pricing procedure is two decimal places.Now we consider a real scneario,consider the net value of 324 quantities of an item calculated is 36,049.86 .When it is divided by quantity  the resulting value of net price is 111.265 but the system shows 111.27 by rounding it off.
    Now here comes the problem,my client needs the rate to be shown on the order script to be two decimal places and the net value should be equal  quantity * net price.So if we apply this,
    324 * 111.27 = 36051.48
    But the net value calculated by the system is 36,049.86.So it can be consluded that:
    "Quantity * Net Price Shown is not Equal to Net Value calculated by the System"
    Need an urgent resolution,project is stuck on this
    Regards,
    Sam Ahmed
    Edited by: Lakshmipathi on Nov 3, 2011 12:14 PM
    Please dont add URGENT in subject or in your post

    Here is the pricing procedure,
    We start with the amount condition types
                                            Unit Price        Units Condition Value
    ZMRP     MRP                     1,700.00           10     PAC     55,080.00      
    ZTRP     Trade Price     1,445.00           10     PAC     46,818.00      
    ZDPR     Dist. Price     1,445.00           10     PAC     46,818.00         (GL)
    Using Trade Price we apply the product discount of 23%
    ZPRD     Product Discount     23.000-     %                    10,768.14-
    Then we send discount amount to the gl by using condition type ZDIS
    ZDIS      Discount Value     100.000-     %           10,768.14-      (GL)
    tHE RESULTING NET VALUE IS  36,049.86      as 46818.00 - 10,768.14
         Order Item value     111.27      1     PAC     36,049.86      
    And the Net Price is 111.27

  • Rounding off to nearest decimal point

    i have these values
    35.2
    35.3
    35.4
    35.5
    35.7
    35.8
    35.9
    36.0
    i am looking for indexes closet 35.74 in my array. (which is index 4.)
    i used the "round to nearest" function and it gave me 36.
    which is index 7.
    what other ways to get the right index?
    Solved!
    Go to Solution.

    You will always have some difficulties with rounding to a specific number of digits after the decimal point because of the way numbers are represented in binary. When expressed in binary 0.1 is an infinitely repeating expression. Regardless of the display the internal representation of the number always uses the maximum resolution for the data type (8 bytes for DBL).
    So you need to be very careful to define exactly what you  want. If you have an array of values (regardless of the way they are displayed) Then you can find the closest to a Test Value by subtracting Test Value from the array and finding the minimum of the absolute values of the differences.
    Note that in the image below the same values are in Array and Array 2 with the display on Array 2 set for 20 siginficant digits. 
    Lynn

  • How to round off quantity in inventory

    Hi,
    How to avoid decimal places for PC(Piece) in the goods movement transactions..  I have given 0 decimal places in CUNI transaction. It is working properly for Production Order during Conrimation but it is not working in Inventory transactions like MIGO, MB1C,MB1A....
    for example When I enter Unint of entry In Alternate Unit say '10 KG'  System Automatically Caliculates quantity in base unit in decimal places say 115.012 PC based on the conversion factor defined in material master.
    My requiremet is the base unit quantity PC rounded off to nearest value in as 115 (PC).
    The same thing is working fine for production order.
    please suggest me how to do.
    Thanks,
    Shekar

    this all depends on your conversion rate enterd in material master.
    if 115.012 PC  equals 10 KG.
    what do you actually want the system to do,
    it would now that you would get 115.012
    you want it to be 115,
    this would then mean that you have to modify the entered quantity from 10 to 9something
    Is it that what oyu want?
    you certainly cannot have 115 PC and 10 KG if you dont change the conversion rate in your material master

  • Rounding-off difference in Line Item vs Invoice

    Can anyone help on how to correct the rounding-off difference in the amount per line item display vs the amount printed in the invoice?  In viewing the document, the line item has an amount of 187.09, meanwhile, when invoice was printed, the amount was 187.10.

    Hi
    Ask ABAPer to modify the format for the invoice amont number field not to round off to nearest value in invoice form.
    Regards
    Laxmiprasad

  • Rounding off currency value

    Hi all,
           Is there a function module to round off the currency value to nearest 0.05 , ie. if the currency value is 10.63, it should be rounded off to 10.65 and when it is 10.68, it should be rounded off to 10.70?
          If yes, could you please let me know?
          Any help in this regard is appreciated.
    Regards,
    Partha.

    hi,
    try this out.here is the sample program.
    pl look into my modified program,
    i am assuming your requirement is like
    if the last digit in your value is < 5. it should be rounded to 5.
      like 10.23 should come to 10.25
    & if the last character value is > 5 , it should be rounded to next value with 0.
        10.67 should be 10.70
        10.98 should be 11.00.
    with this assumption, i developed this small code. let me know, if i am wrong.
    regards
    srikanth
    DATA : V_CURR TYPE VBAK-NETWR,
           V_CHAR(10) TYPE C.
    V_CURR = '10.67'.
    WRITE  V_CURR TO V_CHAR.
    CONDENSE V_CHAR NO-GAPS.
    DATA : V_STRLEN TYPE I.
    BREAK-POINT.
    V_STRLEN = STRLEN( V_CHAR ).
    IF V_STRLEN <> 0 .
      V_STRLEN = V_STRLEN - 1.
      IF V_CHAR+V_STRLEN < '5'.
        V_CHAR+V_STRLEN = '5'.
        V_CURR = V_CHAR.
      ELSE.
        IF V_CHAR+V_STRLEN = '6'.
          V_CURR = V_CURR + '0.04'.
        ELSEIF V_CHAR+V_STRLEN = '7'.
          V_CURR = V_CURR + '0.03'.
        ELSEIF V_CHAR+V_STRLEN = '8'.
          V_CURR = V_CURR + '0.02'.
        ELSEIF V_CHAR+V_STRLEN = '9'.
          V_CURR = V_CURR + '0.01'.
        ENDIF.
      ENDIF.
    ENDIF.
    write :/ v_curr,
             v_char.
    added modified code.
    Message was edited by: Srikanth Kidambi

  • Rounding off to a variable value to 4 decimal values in sap script ouput

    Hi All,
    I have a value getting displayed in sap script output as 235.6789 i want to Round off this variable value to 4 decimal values!
    What is the formatting option need to be used & how!
    Thanks in advance.
    Thanks,
    Deep.

    Hi,
    1.In layout just call that variable, where you need like:
    &variable(.4)&.
    Just see these:
    &symbol(Z)&  Omit Leading Zeros 
    &symbol(S)&  Omit Leading Sign 
    &symbol(<)&  Display Leading Sign to the Left 
    &symbol(>)&  Display Leading Sign to the Right 
    &symbol(C)&  Compress Spaces 
    &symbol(.N)&  Display upto N decimal places 
    &symbol(T)&  Omit thousands separator 
    &symbol(R)&  Right justified 
    &symbol(I)&  Suppress output of the initial value
    Regards,
    If helpful reward with points(Don't forget).

  • Sales Order Net Value - Round off

    Hi Guru's,
    I am having a requirement to round off the total value (VBAK - NETWR) in sales order.
    Condition type DIFF is not fulfilling our requirement because its functioning as an item condition. It's doing round off for each line item.
    Our requirement is Header level net value round off.
    I have searched in SCN but I cant able to find any solution. Kindly throw some light on this subject.
    Regards,
    Dinesh

    Hi,
    After downloaded the note 1158475 implementation status show that cannot be implemented.
    Check the screenshot below.
    Regards,
    Dinesh

  • User exit for rounding off result value

    Hi Gurus,
    Is there any user exit available or std. functionality by which we can round off the result value. My client wants if the value is 192.5 or 191.8 then this value should be rounded off to 195. That means rounding in multiples 0f 5. Is there any exit available?
    Regards
    Amit

    If in QM just specify the correct number of decimals for the characteristic, in your case 0. In config under plant settings you can set up the results recording settings to allow you to record one additional decimal then specified by the characteristic. The result is rounded to 0 decimals when displayed.
    FYI - there should be no reason to have to use user exits to round off decimals in QM.
    Craig
    I didn't read the initial posting correctly.  To round the whole number portion by 5 you will have to provide that logic yourself via the user exits already posted.
    Craig
    Edited by: Craig Snyder on Jan 13, 2010 2:56 PM

Maybe you are looking for

  • Upgrading from Snow Leopard (10.6.8) to Mountain Lion

    So I purchased Mountain Lion online and received the redeem code from Apple. I've redeemed the download for Mountain Lion but have been having issues trying to even initiate the download. I've gone into system preferences and turned off the computer'

  • Ipad 2 crash

    Picked up ipad 2 64g3g yesterday. upgraded to latest software. Used camera attachment to download images from an eos7d which it did successfuly. ipad then crashed when i went to email image. Tried hard reset but it hung. Just have black screen with t

  • Oracle 9i HP 9000 download problem

    Firstly, the files linked to from http://otn.oracle.com/software/products/oracle9i/htdocs/hpsoft.html download with a different size to that listed. I am certain that I haven't downloaded them incorrectly because I have checked the HTTP responses for

  • A MacBook Pro is a Better Deal Than A Windows XP Notebook!!!

    Well I would just like to share the good news with all of you... After going onto www.hpshopping.com , I have noticed that a similiar in power Windows XP Professional laptop with the same speciifications costs more than the all new MacBook Pro when t

  • Airport with a mac & PC on same network

    I have a mac G4 tower and my brother has yet to be converted from the dark side of pc user mermadon-dom. Can I hook his PC to my airport? I don't know what other specks would be needed to help answer his pc is a no name running XP. g4, 30 gig ipod,