Rounding up a variable

Hi All,
Is there any function module or any way to round up a variable.
For ex: 0.8 should become 1
     and 0.3 should become 0.
Thanks.

HI,
Check ROUND FM ....
DATA : V_VAL TYPE P DECIMALS 2 VALUE '5.6',
       V_VAL2 TYPE P DECIMALS 0.
CALL FUNCTION 'ROUND'
  EXPORTING
   DECIMALS            = 0
    INPUT               = V_VAL
*   SIGN                = ' '
IMPORTING
   OUTPUT              = V_VAL2
* 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.
WRITE : V_VAL2.

Similar Messages

  • Round off quantity variable eliminating decimal places

    Hi,
      I have a variable of quan type with value = 1008.123
      I want to round it off with no decimal to be displayed.
      Please suggest.

    Hi,
      Refer
    https://forums.sdn.sap.com/click.jspa?searchID=11055268&messageID=4565374
    https://forums.sdn.sap.com/click.jspa?searchID=11055268&messageID=4721312
    https://forums.sdn.sap.com/click.jspa?searchID=11055268&messageID=2700419
    Regards
    KIran

  • 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).

  • CS5 Advanced Query - using a variable for a column name

    Hi
    I have been using Dreamweaver for a few years now, mostly version 8, but have just moved to CS5 (I teach it - among lots of other thing -  at what in the US would be a community college).
    I have problem with a page in CS5 that worked fine in my old version 8 edition.
    I am using PHP and MySQL as my server technologies
    I have a CD database and have constructed a Search Page which has a Form with a Text Box (stext) for the search criteria, and 3 option buttons to select the DB column I want to search on.  The option buttons are called sfield - and have values band, title, and/or year these will be passed to my display page (display.php) via GET array URL Parameters.  They are passed fine.
    I want to be able to enter "Pink" into the search text field, click the Band option button, and then my data displayed would inlude CDs by any band with Pink in their name i.e. Pink Floyd.  If I put 1989 and click the year option button, I search for all CDs from 1989 and so on.
    On my display page I created a recordset and selected my MySQL Server, DB Table, and using the simple dialogue selected band as the Filter and "contains" and the URL Parameter stext.   This all works as expected. I put in a  dynamic table and when I run it to test it, it will search on band only and works fine.
    Its when I try to select the column to search I get a problem.  I go to the advanced recordset dialogue.  I have the SQL
    Select * from newellcds where band like %colname%
    I need to change this to add a new variable, lookfield, which will hold my column selection from the option buttons (URL parameter: sfield), so I create the TEXT variable, with band as the default and the value of $_GET['sfield'] and put it into my SQL
    Select * from newellcds where lookfield like %colname% - and it doesn't work!!!  I always get no return from the database.
    After much experimentation, I echoed the Dreamweaver generated SQL on the screen and when I entered Pink and selected band on the search page, the Display SQL was displayed as:
    Select * from newellcds where 'band' like '%Pink%'
    Dreamweaver is putting single quotes round the value returned by my lookfield variable 'band' in this case.  If I enter the SQL without the quotes round Band into MySQL it works, with the quotes I get no returns.
    After this very long description - does anyone have an idea how to get rid of the quotes round my lookfield variable???
    How do I create a search page with two values passed - the actual criteria to search for, and the field to search for it in?
    Any help would be greatly appreciated.

    I don't have anything useful to contribute because I don't use DW to create queries, and you are not looking for help writing the query. You just want to get rid of the single quotes, which I can't help with.
    But based on your description, shouldn't the query be
    SELECT * FROM newellcds WHERE $sfield LIKE '%$stext%'
    If not, then I am not following.

  • How to assign a calculation to a variable in RTF file ?

    Hello,
    I am performing a series of  if-end if statements to calculate the "Days_Late" --
    <?if:DAYS_LATE < 0?> <?xdoxslt:round((sum(if:DAYS_LATE ) div count(PAYMENT)),0)?> <?end if?>
    <?if:DAYS_LATE = 0?>***<?end if?>
    <?if:DAYS_LATE >= 0?> <?xdoxslt:round((sum(if:DAYS_LATE ) div count(PAYMENT)),0)?><?end if?>
    I would like to assign the above code to a variable and use that variable in the following logic <?xdoxslt:ifelse(VARIABLE>0,round(VARIABLE),-1*round(xdoxslt:abs(VARIABLE)))?>
    to perform a round_up function ("Symmetric" rounding). Oracle doesn't have a function for this yet ..
    How can I make this assignment directly in the .rtf file ?
    Thanks,
    ATP

    Hello all,
    I did not want to change the data (sql).
    Also, I did try to make it run using the xdoxslt:set_variable () function and xdoxslt:get_variable() function. However, this was not required and was making it more complex than required.
    It is now solved using a formula for symmetric rounding (rounding away from 0) :
    <?xdoxslt:ifelse(VARIABLE),-1*round(xdoxslt:abs(VARIABLE))?>
    I substituted the VARIABLE with my calculation : (sum(DAYS_LATE ) div count(PAYMENT))
    Thanks a lot for the answers and offers to help

  • Round up character data?

    I am a newbie in SAP.
    I have a variable declared like this:
    DATA y_dots(6) TYPE c.
    I performed some mathematical operation on this variable and it ends up as 56.5.
    So do I round up this variable so that it becomes 57 or 56?
    Please help and I will reward you.
    Thanks

    Hi,
    Just do like this,
    define one local variable with type p then move your field (type c field) into this variable and display this.
    sample code shows here how to do that,
    DATA: data(5) TYPE c VALUE '12.60',
               data1 type p.
             data1 = data.
    WRITE: data1, data.
    it'll solve your problem.
    seshu.

  • Rounding a double value

    What is the easiest way to round a Double variable to 2 significant figures?
    Cheers Mike

    Oh, classical and very typical question on this forum.
    The short answer is nope. You don't do that and you don't need to do that. If you really really have to must doing that, you used the wrong type - double.
    By definition, double is an approximation. No gurantee on precision lose.
    --lichu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Event handling in JMenu in JPanel

    Hi,
    I'm writing a small register program GUI. I have a problem with ActionListener in JMenu. I wrote a JPanel which creates a JMenu and that works just fine. The problem is that id doesn't give any event signals. I have another class which impelemets ActionListener and it works fine with JButton (another panel for buttons), but not with JMenu.
    Below is the JPanel for JMenu and Application which implements the ActionListener. Do you see anything wrong? I really can't imagine why I cannot get the action signals. JPanel is defined in JFrame as it should be. Have you got any ideas?
    Regards,
    Marko
    class MenuPanel extends JPanel {
         protected JMenuBar menuBar;
         protected JMenu menu;
         protected JMenuItem loadRegister;
         protected JMenuItem saveRegister;
         protected JMenuItem information;
         protected JMenuItem quit;
         public MenuPanel(Application application) {
              menuBar = new JMenuBar();          
              menu = new JMenu("Tiedosto");     
              loadRegister = new JMenuItem("Lataa");
              loadRegister.addActionListener(application);
              saveRegister = new JMenuItem("Talleta");
              saveRegister.addActionListener(application);
              information = new JMenuItem("Tietoja");
              information.addActionListener(application);
              quit = new JMenuItem("Lopeta");                    quit.addActionListener(application);
              menu.add(loadRegister);
              menu.add(saveRegister);
              menu.addSeparator();
              menu.add(information);
              menu.add(quit);          
              menuBar.add(menu);
    class Application implements ActionListener {     
         // Define CardPanel
         private CardPanel cardPanel;
         // Define linked list for cards
         private CardList cardList = null;
         // Constructor. Initializes cardPanel and cardList
         public Application(CardPanel cardPanelRefrence) {
              cardPanel = cardPanelRefrence;
              cardList = new CardList();
         public void actionPerformed(ActionEvent action) {
              String actionPerformed = action.getActionCommand();
              if (actionPerformed.equals("Lataa")) {
                   load();          
              if (actionPerformed.equals("Talleta")) {
                   save();          
              if (actionPerformed.equals("Tietoja")) {
                   info();          
              if (actionPerformed.equals("Lopeta")) {
                   System.exit(0);
    // Continues with the methods...

    Well, I found the answer. Heh, quite easy one but it took a while before I found it..
    Just if you ever have similar problem. The problem was that in my JFrame I didn't create an object of class (Application) which implement s the ActionListener before using it as a reference in creating JPanel object. Quite confusing explanation, but here the code. This code was in my JFrame which was not included in this question.
    private Application application;
    private MenuPanel menuPanel;
    application = new Application(cardPanel, rightInfoPanel);
    menuPanel = new MenuPanel(application);
    These two were introduced other way round, so that variable "application" was null. What a problem in fact.. :)
    - Marko

  • Why updates on some tables with always on synchronize mode take * 100 than when asynchronize mode

    I have Always-On synchronization on some databases, We want to change from asynchronize mode to synchronize mode, I tested to see what the  change in performance between the two, and found that in general the select statements keep the same
    duration with and without synchronize mode, most of the update\insert usually take around * 4 times from the asynchronize mode, BUT some updates take much longer. I would like to understand why things take MUCH longer (I understand that working with synchronize
    mode is a 2 phase commit and should take * 4 times, but I can't understand why some of them take 50 - 100 times more).
    1. One query is an update made on a table with few records (up to 40 records), this update run 250K times a day, and a very simple update on this table takes * 98 than without synchronize mode
    1. An update on a big table with 2 million records, using a query that specify the unique column in the primary cluster key, takes 50 times more.
    What are  the factors that have dramatic influence on performance when 2 phase commit (asynchronize mode) is used?

    I've never even looked at the details for SQL Server, but on any kind of a system doing synchronous updates, you have to figure there is a fixed cost, a variable cost, and a queuing cost.  The fixed cost always hits whether its a big transaction or
    a small transaction, let's guess it's about 0.1 seconds for a round trip.  Variable cost depends on how much is updated, let's say it's linear, and is maybe 0.05 seconds for a couple of small rows.  The queuing cost varies from 0 to huge.
    So if you have a small transaction on a local system that takes 0.05 seconds (50 milliseconds), then just one will incur the local 0.05, plus 0.10, plus 0.05, and zero queuing cost, so 0.05 -> 0.20, about 4x.
    But if you have something that runs 250k times a day I hope it's faster, maybe it's only 0.01 seconds locally, and that turns to 0.01 + 0.10 + 0.01 + q, so 0.01 -> 0.12+q, so it's at *least* 12x slower, and maybe if you get 100 of them
    in the same second you start incurring queuing delays also, in fact you may have similar queuing delays on the local system and remote system besides any communications queuing, but if just the synchronization system has some queuing limits and it even gets
    to 0.30 seconds then 0.01 -> 0.42, or 42x, and you start seeing what can happen.  If your local transaction is only 0.001 seconds when not synchronized, then you'd have 100x slowdown just on the fixed overhead!
    IOW, synchronized systems and tons of small, fast transactions just don't fit together very well.
    HTH,
    Josh

  • Datetime arithmetics in OLAP DML

    Hi.
    I have some miscalculations in my OLAP DML programs.
    For example I want to subtract 5 min. from some datetime variable
    NLS_DATE_FORMAT = 'dd.mm.yyyy hh24:mi:ss'
    SHOW TO_DATE('10.02.2005 10:00:00') - 1 / 24 / 12
    I've got
    10.02.2005 10:05:00
    I've discovered miscalculation take place only while subtracting fractional numbers. Addition works accurately with any numbers.
    Can anyone help me?
    Thank you.
    Andrew

    Hi Lars
    I'm sorry. I wrote first message from memory and I took arbitrary time value.
    I discovered that problem take place with round day datetime variable.
    For example
    NLS_DATE_FORMAT = 'dd.mm.yyyy hh24:mi:ss'
    SHOW TO_DATE('10.02.2005 00:00:00') - 1 / 24 / 12
    I've got
    10.02.2005 00:05:00
    But that is not a problem in PL/SQL, only in OLAP DML.

  • Apex - Audit Trail With External Database

    I'm currently trying to setup a primitive audit trail that allows me to record create data, create user, update date, update user. I currently have 3/4 however I can't get the username into database as V('APP_USER') is within Apex and the database is in Oracle 10G elsewhere.
    Any suggestions or alternative ideas?

    f1f7a787-7f56-4451-8300-5a9a0215226b
    So v() and apex_application.g_user are unavailable in the trigger code on the external database.
    But procedures and package variables from the external database are available on the database running APEX.
    What I would do is create a package with a package variable that will hold the apex user. ( in the external database)
    Then in application definition > Database session> initialization PL/SQL code set this package variable to the apex user.
    Clear the package variable again in the cleanup code.
    Using a package variable will mean that the value is aviable during the whole database session but not outside of is.
    In apex every page load or submit and following page load is a database session.
    Now the package variable will be set when it is a apex user and null when it is a database user.
    Using a nvl round the package variable with user as alternative will give the apex user when the action was done by a apex user and the database user when not.
    Nicolette
    Ps changing your handle or at the very least signing your post will result in a more friendly greeting.

  • Chnfind unable to find the decimal type by variable and sometimes "Round" command

    Dear all,
    During the work with Diadem I got two troubles. Could you please take a look and show me the wrong if you find the issue?
    1.) Here is my trouble as we see the photo below. It is most important problem which I have. I really have no idea why it could happened. It is alway happened to find a value with decimal type's variable, and even that variable is changed  to "str()".
    setlocale("en-gb")
    dim Min_point,Index_low,result
    Min_point=val(Data.Root.ChannelGroups(1).Channels("CopyYangle").Properties("minimum").Value)
    Min_point=round(Min_point,6)
    Min_point=str(Min_point)
    msgbox("The Min.Value is: "&Min_point)
    Index_low=Chnfind("ch(""CopyYangle"")<="&Min_point&"", 1)
    msgbox("Index No. of Min. Value is: "&Index_low)
    Index_low=Chnfind("ch(""CopyYangle"")<=-0.11374 ", 1)
    msgbox("Index No. of Min. Value is: "&Index_low)
    2.) Still the problem with ChnFind()  or  ChnFindreverse().   If I change the Rounds off a number to the nearest integer with the function "Round()" it might not work in ChnFindreverse(). Such like it works under 4, 6, 8 and even 7 but doesn't work with 3 and 5. Is this logical?
    setlocale("en-gb")
    Dim XE, Xchannel, Ychannel,round_N0
    Xchannel = "[2]/Right"
    T1 = Xchannel
    R1 =val(Data.Root.ChannelGroups(2).Channels("Right").Properties("maximum").Value)
    round_N0=4 ' <========= 3 and 5 Not work, 4, 6, 7, 8 .... work
    R1 =round(R1,round_N0) ' <=========
    msgbox("Max. point is: " &R1 &VbCrlf& "Round Nr is: "&round_N0)
    L1 = ChnFindReverse ("Ch(T1)>=R1",0)
    msgbox("Index number for Max.Point is: "&L1 &VbCrlf& "Round Nr is: "&round_N0)
     .tdx is a valid extensions for an attachement?
    If you couldn't open the TMD file. Please remove ".tdv" the attacments file name to make sure it is "ChnFind.tdx" but not "ChnFind.tdx.tdv".
    Kind regards / Mit freundlichen Grüßen
    J.Huang
    Attachments:
    ChnFind.TDM ‏5 KB
    ChnFind.tdx.tdv ‏39 KB

    Hello J.Huang,
    I downloaded the files and was able to get it to work. It looks like when you format the minimum value to a string, you loose precision and then ChnFind doesn't find the value your are looking for. He is an example which worked for me :
    Set oChnY = Data.Root.ChannelGroups(2).Channels("Right")
    sgValue = str(oChnY.Properties("minimum").Value,"d.ddddddddddddddd")
    Index = ChnFindReverse("Y<="&sgValue,,Array("Y"),Array(oChnY))
    LogFileWrite(Index)
     Using symbols (parameters 3 and 4) is not necessary to get the solution. The key is teh second value for "str" which formats using more digits. As soon as you reduce the number of digits, you may no longer get a result.
    Ther is an alternative to ChnFind, in case there is only one occurance in teh signal which has the minimum value
    Set oChnY = Data.Root.ChannelGroups(2).Channels("Right")
    Index = PNo(oChnY,oChnY.Properties("minimum").Value)
    LogFileWrite(Index)
     I hope one of the two options works for you. I tested the approach with teh first channel too and it worked as well

  • Use of variable types and rounding...

    I'm kinda confused on what variable types to use. I want it so that when I divide two numbers, it'll either round up or down, and give me a rounded number w/o a decimal.
    Examples...
    184/2683=7
    164/2683=6
    I have been fiddling with it for a while now, and I keep getting rounded down numbers, even if the decinal is more than .5. Thanks in advance!

    184 / 2683 = 0.068579947819604919865821841222512 -> 0.07
    164 / 2683 = 0.061125605665300037271710771524413 -> 0.06
    Use Math.rint (please read the javadocs...) and some scaling (multiply by 100.00, divide by 100.0 etc).
    Beware - when printing your result could be:
    0.070000000000001
    or
    0.069999999999998
    instead of the expected value 0.07
    for instance, due to the properties of floating-point arithmetic. If you want to round the number only for displaying it, use java.text.DecimalFormat or java.text.MessageFormat.

  • Rounding a variable, can this be done.

    Hi,
    I'm trying to round a variable. Howerver, nothing appears!
    I know that numbers can be rounded, but I can't get the bit below to work....
    <?xdoxslt:set_variable($_XDOCTX, 'diff', number(A.OXF_UNRST_VALUE_YTD) - number(A.OXF_USTRCT_EXP_AMT_YTD))?><?xdoxslt:set_variable($_XDOCTX, 'testa',(number(xdoxslt:get_variable($_XDOCTX, 'diff')) div number(A.OXF_UNRST_VALUE_YTD))*100)?>
    <?xdofx:round(number(xdoxslt:get_variable($_XDOCTX, 'testa')),0)?>
    Any suggestions most appreciated.

    Hi,
    Thanks for taking the time to reply. I did wonder if the namespace was correct, but alas did not try changing it from xdofx.
    The XDOUserGuide.pdf has the reference below:
    round <?xdofx:round ( number [, integer ] )?>
    ROUND returns number rounded to integer places right of the decimal point. If integer is omitted, then number is rounded to 0 places. integer can be negative to round off digits left of the decimal point. integer must be an integer.
    Cheers,
    Steve.
    Edited by: user7137712 on 01-Dec-2011 07:48
    Edited by: user7137712 on 01-Dec-2011 07:48

  • Round float variables

    hi folks: i need to round the values in my float variables to 2 points precision like this x.xx, so that i can compare them easily.
    for example: 0.08765432 and 0.09087654 would be esaier for me to compare if i could round them to: 0.09 and 0.09(equal). otherwise those numbers will, virtually, never equal ech others.
    is ther a way to round up my float variables to x.xx precision?
    thx

    Rather than comparing string representations of integers, I'd suggest just using a delta:
    double delta = 0.0000005;
    double someNumber1, someNumber2;
    // get values for someNumber1, someNumber2
    if (Math.abs(someNumber1 - someNumber2) < delta) {
        // say they're equal
    }But actually using BigDecimal is probably the better choice.

Maybe you are looking for

  • Error while uploading tiff file using report "RSTXLDMC"

    Hi Experts, I am trying to upload .tif file into SAP usinf report "RSTXLDMC". Getting below error. Uploading TIFF Files to SAPscript Texts Load File c:\file.tif The file contains    134,412  bytes This is a TIFF file with MOTOROLA byte order First IF

  • Why is firefox having so much trouble finding servers?

    The problem of Firefox not being able to find the server requested is becoming more and more frequent. Every time it happens, I have to reload at least once, sometimes twice, before the server is found (as it almost always is). I have never had this

  • PARAMETERS of Multiple values

    ok i have a field called Country and a field called city. I have a function that calculates the total Population of the country based on the number of people in each city. But for the sake of testing the function i made country = America. But there a

  • Background Movie becomes slow motion

    Hi everyone, I've imported a background movie in my Live Type file so that I would know where on the screen and for how long I should place my graphics. However, it turns out that when I play the movie on the canvas, it's in slow motion. Is there a w

  • Installing flash player on my kindle

    Installing flash player on my kindle?