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.

Similar Messages

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

    Create one more variable in Global definitions with only 1 decimal place.
    Assign value of qty to this new variable.
    SAP automatically takes care of the rounding.
    And then print this new variable rather than qty.
    You can write all these in a code block.

  • Change of the quantity field to 5 decimal places in SAP

    Hi Gurus,
    The quantity field is appearing with 3 decimal places in BOM, Process Order, etc. Is it possible to make the decimal places to 5.
    All the decimal digits from SAP are 3 digits. We have an interface through which the data flows from another legacy system (Fow system) to SAP. And the Fow system setting was 5 digits. The issue is some of the raw material requirement qty was really minor and it might be below the decimal 3 digits.
    In that case, when the data flows to SAP from Fow system it will cause the material stage failure. so please help me to investigate how to let the SAP also could have the 5 digits decimal. Thanks.
    Regards
    Brijesh

    Dear ,
    Its SAP standard ,to put and use decimal places in BOM qty .You can use upto 3 decimal places in BOM qty.
    At SE11 you need to see what measure field is linked to the quantity field.Then goto tranaction CUNI and chage the decimal places of the unit of measure for the qty field unit , it will not allow you more than 3 decimal places in case of BOM qty.
    You have following choice :
    1. With the access key make changes in the standard program and take help from ABAPer
    SAPLCSDI, Table Name-RC29P, Field Name- MENGE.
    2) Change the base quantity in BOM header to 1000 aand accordingly change the component quantity.
    Hope this is clear
    Regards
    JH

  • Amount has moved one decimal place in the report

    Hi,
    I am looking in to a report at present, Transaction amount has moved one decimal place, while the local amount stays the same. Any one could tell me the possible reason for this?
    Thanks in advance
    RN

    Hi,
    Check this link,
    http://sap.ittoolbox.com/groups/technical-functional/sap-bw/key-figure-in-cube-is-multiplied-by-100-when-displayed-in-bex-report-743076
    same issue find in this.
    Hope it will help you.
    Thanks,
    Hema

  • Any function module to round of a value to two decimal places?

    Hi gurus,
    Any function module to round of a value to two decimal places?

    Hi,
    you can use FM 'ROUND'.
    Thanks.

  • Reg: Quantity field taking as decimal values

    Dear Experts
    In the Bapi BAPI_SALESORDER_SIMULATE the structure BAPIITEMIN contains a field Req_qty that has the data element WMENGC which is taking the input with 3 decimal points even though the domain doesnt contains any decimals, because of this im facing the problem while giving the input.
    Is there any functional requirement to avoid that quantity field taking those 3 decimals
    eg: Original Value: 1000
          Input Value(Converted Value)    : 1.000
    Kindly suggest me a solution to sort out the issue.
    Regards
    Arun.P

    well i suspect that this bapi also has a currency field, which you should fill.
    If he knows the currency he should be able to find out how much decimals there are customized for this currency, and then probably he will do it right.
    oh lol you are talking of quantities and not values... sorry forget about my comment...
    Edited by: Florian Kemmer on Jul 22, 2010 2:37 PM

  • Rounding off a float to two decimal places

    I want to make a function where I shall pass a float and and integer.
    The float shall have to be rounded off to a value in the integer.
    Can anyone please suggest how to round off a float.
    E.g.: if the float is 12.56890 and I want to round it off to 2 decimal places, then it should be 12.57.
    Regards
    Hawker

    I didn't mention any datatypes like float, double.True, but that is what the question is about, so you weren't answering the question. For a change.
    As I mentioned, that was just a mathematical steps to round of the floating point value. (Not in any programming languages point of view).False. You didn't mention that at all.
    This is the code for that in java.So here you are mentioning datatypes and floats for the same piece of mathematics that you have already been told, with reasons, doesn't work in floating point.
    which seems to be working fine
    Seems to. What evidence do you have that the float actually got rounded? As opposed to got displayed as rounded? Which is not what the OP asked for.
    And of course all that code seems to do is round 0.01 to two decimal places, which again is not what the OP asked for.
    For any remaining fans of this 'technique', please explain the behaviour of the following code:
         public static void     main(String[] args)
              int     count = 0, errors = 0;
              for (double x = 0.0; x < 1; x += 0.0001)
                   count++;
                   double     d = x;
                   int     scale = 2;
                   double     factor = Math.pow(10, scale);
                   d = Math.round(d*factor)/factor;
                   if ((d % 0.01) != 0.0) // if 'd' really has been rounded this should be zero
                        System.out.println(d % 0.01);
                        errors++;
              System.out.println(count+" trials "+errors+" errors");
         }

  • Rounding off Amount which has 3 decimal places

    Dear All ! !
    Urgent Help required i need to round the Amount of 3 decimal pleaces for example
    300.777 should be round to 300.800
    300.340 should be round to 300.300
    or
    300.977 should be rounded to 301.000
    Payroll in international for Bahrain and Oman both currency value is too high but they use to round after decimal. Can any one Guide any function any operation or some other solution will be highly regarded
    Thanks
    Syed Baddar

    Hi
    You can do this by writing a rounding calculation rule.
    Or ask an ABAPer to write a simple routine in payroll driver program RPCALCX0. It has an exit where he/she can write a small routine for this.
    Regards
    Waz

  • Rounding and remving of zeros at decimal places

    i have columns like
    quantity, weight, volume, length, width, height
    if its values are 4.666 means under 5 then it should conver to 5 else if its 5.677 then it should round off the value and ifs 5.000 then it should remove the 000 and print 5 on screen is there any function to do this step.

    Hi,
    Check this sample:
    DATA: WA_INPUT TYPE P DECIMALS 8,
    WA_OUTPUT TYPE P DECIMALS 2.
    WA_INPUT = '5678.65800341'.
    CALL FUNCTION 'ROUND'
    EXPORTING
    INPUT = WA_INPUT
    IMPORTING
    OUTPUT = WA_OUTPUT
    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: WA_OUTPUT.
    Regards,
    Chandru

  • Rounding quantity field

    Hi All!
    I want to round quantity field to one decimal place instead of three decimal places.How to achieve this I know there is FM to convert to 2 decimal places but how to get it for one decimal place.
    Regrads
    Praneeth

    <b>WRITE .... <f> <option>.
    U can use into another field</b>
    Formatting options for numeric fields
    Option
    Function
    NO-SIGN
    The leading sign is not displayed on the screen.
    DECIMALS <d>
    <d> defines the number of digits after the decimal point.
    EXPONENT <e>
    In type F fields, the exponent is defined in <e>.
    ROUND <r>
    Type P fields are multiplied by 10**(-r) and then rounded.
    CURRENCY <c>
    Format according to currency <c> in table TCURX.
    UNIT <u>
    The number of decimal places is fixed according to unit <u> specified in table T006 for type P fields.
    DATA pack TYPE p VALUE '123.456'
                            DECIMALS 3.
    WRITE pack DECIMALS 2.
    WRITE: / pack ROUND -2,
           / pack ROUND -1,
           / pack ROUND 1,
           / pack ROUND 2.
    output
    123,46
    12.345,600
    1.234,560
        12,346
         1,235
    regards
    vinod

  • Decimal places in quantity depending on currency

    hi
    i m doing an alv list display in which i need to display a quantity field with 3 decimal places for some currencies, but for one particular currency such as 'AED'
    that field should display only 2 decimal places in the output.
    regards
    Zarina

    Hi Zarina,
    Populate decimals_out with 2 for this field while building the fieldcatalog.
      g_t_fieldcat-decimals_out = 2.
    Note: don't declare the field as currency which will overwrite above setting.
    i.e., don't use g_t_fieldcat-cfieldname in this case.
    ==============================================
      g_t_fieldcat-seltext_s =  'USD Equi'.
      g_t_fieldcat-seltext_m =  'USD Equi'.
      g_t_fieldcat-seltext_l =  'USD Equivalent'.
    g_t_fieldcat-cfieldname = ' '.
      <b>g_t_fieldcat-decimals_out = 2.</b>
      g_t_fieldcat-just      =  'R'.
      modify g_t_fieldcat index zindx.
    ==============================================
    Hope this helps you.
    Regards,
    Vicky
    PS: Award points if helpful

  • Quantity Field Display

    Hi,
    I am displaying the quantity field in the sap script layout.But in the quantity field having 3 decimal places.
    Ex: 3.400 is there i want to display 3.4
        3.000 only i want to display 3
        3.740 -
      3.74 like that i want.
    I want to omit the zeros after decimal places.
    Please give me the solution.
    Regards,
    Jenny

    Hi Janardhan,
    Do one thing in your print program make us of following line of code
    shift wl_local right deleting trailing '0'.
    where wl_local will containing your quantity..
    This will solve your prob...
    Enjoy SAP.
    Pankaj Singh.

  • Decimal places not visble depending on unit of measure

    Hi,
       I have a fields in a table line that is a quantity field with 3 decimal places, I also have a unit of measure associated with that quantity.
    When my unit of measure is EA the quantity displays with 3 decimal places, but when the unit of masure is M it displays with NO decimal places. The display becomes very ugly when there is a mixture of units of measure.
    Anyone know why thsi is happening?
    Cheers,
    Ross

    I'd suggest that there is a conversion routine specified on the domain of the amount field - probably "CUNIT" which takes the value of the unit, looks it up in T006 and then applies relevant formatting to the field.
    This isn't really a WDA thing - it's nice that WDA does this (well perhaps not in your case but it is standard behaviour for amounts and unit fields.
    Cheers,
    Chris

  • Quantity Field Display in Sap Scripts

    Hi,
    I am displaying the quantity field in the sap script layout.But in the quantity field having 3 decimal places.
    Ex: 3.400 is there i want to display 3.4
    3.000 only i want to display 3
    3.740 -
    3.74 like that i want.
    I want to omit the zeros after decimal places.
    Please give me the solution.
    Regards,
    Jenny

    As it is quantity field, it will print even the decimal points...U can try this...move the value to a char variable and use truncating to remove zeros by deleting them and use this value in ur script to print the value.

  • Rounding to 1 decimal place.

    Hello again.
    I have a method called "findTheAverage" which takes in an array of integers as a parameter and then calculates and returns the average as a float.
    What I want to do now though is create another method called "roundTheAverage" which takes in the float average variable from the previous method, rounds it to one decimal place, and then returns it as a float called roundedAverage.
    Could anybody help me in achieving this?
    Thanks.

    I'm fairly new to Java, hi.
    Oh I know all about you.
    I'm trying to write a method which takes in a float
    called "number" and then returns this float to two
    one decimal places called "roundedNumber".
    This is not the way this works. You have to write your own code.
    >
    Could you type me the code that I'd need to do this
    perhaps?
    Nope.
    It's a pretty simple problem I think, and it's
    wasting an enormous amount of time figuring it out.
    You are right on both counts. It is very simple and you are wasting alot of everyones time.
    >
    thanksAPI Application Programming Interface
    Javadoc API
    In context for this site means the documentation for the basic packages that make up the core Java API.
    I provided a link earlier to the Javadocs for java.text.DecimalFormat
    If you can't figure it out you need to HIRE A TUTOR.

Maybe you are looking for

  • What is wrong with as3

    this is not a question about 'how i do X'. is rather a 'discussion' (flame or whatever, but to defend or argue about aspects, not people) about 'what is wrong with as3' and what aspects whould be taken into consideration for updates. right now i am u

  • Trouble getting "back to my mac" to work on new Air - and really need this functionality

    This is sort of one of those "asked and answered" threads, but I wanted to share my solution. I love being able to see my other computers remotely. I don't think Apple sells the functionality of remote desktop enough. I have a laptop and I also run t

  • Mexico Telcel LTE iPhone 5 when will it be available?

    I called telcel to ask when they would provide LTE for the iPhone and their answer is that it is available but they can not provide the service because Apple has not released the license, does anybody know if this is true and if so when will Apple le

  • One user cannot see Inactive Addresses in Account Overview

    One user cannot see Inactive Addresses in Account Overview in the CRM 7.0 IC. This user has the same roles and authorizations as all the other users. We have also performed a user comparison in CRM and ERP and have also reset the user buffers in both

  • Error in Sync Bo Creation

    Hi I am on WAS 6.40. And have defined my two own RFC's to be used for GetDetail and GetList. When I am generating the SyncBo. It gives the following error <b>'Function modules from the function pool Z_MEREP_GEN_T01_ZMIDELV contain syntax errors'</b>