Decimal format to 2 decimal places ????

Hello Everyone,
I have created a web dynpro application which to display a report depending on the data given by the BAPI. But there is some issue with the numeric data returned by the BAPI.
For ex - if the BAPI returns 5.00 the value is displayed in the report as 5.
I want uniform decimal values till 2 decimal places. For example 5 shd come as 5.00, 2.1 shd come as 2.10 etc.
I searched SDN abt this, and found many threads relating to this.
I tried using decimal format, creating a simple dictinary type, but using all this what happens is the value basically changes to a string format, this implies that the value is displayed in the table as "left-aligned".
Where- as we need the decimal numeric values to be right-aligned.
Any thoughts how to achieve this.
Please correct me if I have missed out on anything.
Thanks,
Samta

Hi,
From wat i understood.. u have a attribute coming from BAPI.. which you want to display with two decimal places,,
In this case.. assuming it is coming with 2 decimal places from the backend..  create a value node.. inside the node which contains the output data. set its carinality to 1..1 .. create a value attribute of type big decimal in it.. or probably string.. if there is an issue in displaying BigDecimal directly..
map this new attribute to the necessary column in the table..
BigDecimal value = new BigDecimal("the actual value in string or long").setScale(2);
assign this to the value attribute created..
(If alignment is the problem.. set the column 's textview property halign to right.. and layout as block or paragraph.. )
Regards
Bharathwaj
Message was edited by:
        Bharathwaj R

Similar Messages

  • Formatting currencies and decimal places

    I'm currently using NumberFormat.getCurrencyInstance() to format numbers as currency. However, one problem I'm having is that I'd like values with no cents to be formatted with no decimal places, and any values with cents to be formatted with the usual 2 decimal places. For example:
    17 would be formatted as $17
    17.45 would be formatted as $17.45
    17.4 would be formatted as $17.40
    The last one is the tricky part--I've tried formatter.setMinimumFractionDigits(0), and this works great for the first two cases. But for the last case, the number gets formatted as $17.4.
    Basically my problem is I want a number to be formatted with zero or two decimal places and nothing in between. Is there an easy way to do this?
    Thanks in advance.

    Otherwise you are likely to find that you are getting .00 due to errors from previous calculations. You are right. Adjusted it to Locale aware
    import java.text.FieldPosition;
    import java.text.NumberFormat;
    import java.text.ParseException;
    import java.text.ParsePosition;
    import java.util.Locale;
    public class SpecialCurrencyFormat extends NumberFormat {
        private static final long serialVersionUID = 1L;
        private final NumberFormat noDecimals;
        private final NumberFormat decimals;
        private final double maxDifference;
        private final double factor;
        public SpecialCurrencyFormat() {
         this(Locale.getDefault());
        public SpecialCurrencyFormat(Locale locale) {
         decimals = NumberFormat.getCurrencyInstance(locale);
         noDecimals = NumberFormat.getCurrencyInstance(locale);
         noDecimals.setMaximumFractionDigits(0);
         maxDifference = Math.pow(10, -decimals.getMaximumFractionDigits()) * .5;
         factor = Math.pow(10, decimals.getMaximumFractionDigits());
        @Override
        public StringBuffer format(double number, StringBuffer toAppendTo,
             FieldPosition pos) {
         double adjustedValue = (Math.round(number * factor)) / factor;
         if ((Math.abs(number - Math.round(number)) < maxDifference)) {
             return noDecimals.format(adjustedValue, toAppendTo, pos);
         } else {
             return decimals.format(adjustedValue, toAppendTo, pos);
        @Override
        public StringBuffer format(long number, StringBuffer toAppendTo,
             FieldPosition pos) {
         return noDecimals.format(number, toAppendTo, pos);
        @Override
        public Number parse(String source, ParsePosition parsePosition) {
         return decimals.parse(source, parsePosition);
        public static void main(String[] args) {
         NumberFormat nf = new SpecialCurrencyFormat(Locale.US);
         double[] values = { 10000, 1000, 100, 10, 1, 10.1, 10.01, 10.001,
              10.002, 10.003, 10.004, 10.005, 10.006, 10.007, 10.008, 10.009,
              10.010 };
         for (double value : values) {
             print(nf, value);
        private static void print(NumberFormat nf, double number) {
         String formatted = nf.format(number);
         try {
             System.out.println(number + "\tas " + formatted + "\tand back "
                  + nf.parse(formatted));
         } catch (ParseException e) {
             e.printStackTrace();
    }The value adjustedValue is needed since NumberFormat doesn't seem to round the value. It just breaks.
    Piet

  • Convert a column in Numbers that is currently in HH:MM format to decimal format.

    I need to Convert a column in Numbers that is currently in HH:MM format to decimal format.  IE 6:30 to 6.5

    Rj,
    There are two possibilities here. Your HH:MM could be a Date/Time value or a Duration.
    Let's assume your data is in Column A.
    If it's a Date/Time value, do the conversion with the expression:
    =TIMEVALUE(A) * 24
    If it's a Duration value, do the conversion with the expression:
    =DUR2HOURS(A)
    In both cases, remember to Format the result to Number with at least one decimal place.
    Regareds,
    Jerry

  • Currency decimal format

    Hi,
    I wanted to know if there is any table which stores the currency format for decimal places. for e.g some currencies use a period to indicate the decimal place while some use a comma.
    if the amount is 127.54
    in USD it will be 127.54
    in FRF it will be 127,54
    Is there any table which stores this information as to which currencies use comma and which use period.
    Thanks,
    Prasy

    I think the decimal format is controlled by the user setting not the currency being output. For example:
    REPORT ztest LINE-SIZE 80 MESSAGE-ID 00.
    DATA: amt TYPE bseg-dmbtr VALUE '123.45'.
    WRITE: /001 amt CURRENCY 'FRF'.
    gives output for me as:
    123.45
    Rob

  • How to stopping rounding  using decimal format

    my problem is as
    1. I am taking a double input in a jtextfield
    2. Now i am using decimal format to round it to 6 decimal places
    Now , how to make sure that decimal format while formatting do not round
    like If input is 1.2345678 i want to get 1.234567 not 1.234568

    That's not really an SCCSE.
    Anyhow, why not just use Double.parseDouble() if you don't want any rounding etc. Don't forget to catch the NumberFormatException:
    parseDouble
    public static double parseDouble(String s)
    throws NumberFormatException
    Returns a new double initialized to the value represented by the specified String, as performed by the valueOf method of class Double.
    Parameters:
    s - the string to be parsed.
    Returns:
    the double value represented by the string argument.
    Throws:
    NumberFormatException - if the string does not contain a parsable double.
    Since:
    1.2
    See Also:
    valueOf(String)

  • How do I convert an 8 bit serial data string I have received (say 01110101) into decimal format??

    I am having a hard time finding a function that will help me convert an 8 bit serial data string I have received (say 01110101) into decimal format.

    When you have your front panel displayed, you should a whole palette of controls that you can place on the front panel. If the palette is not displayed, thne just right click on your mouse and it should appear. The upper left most set of controls on the palette is Numeric. Go there and select Numeric Indicator to display a numeric output. On the diagram, you can also right click the output 1 and select Create>Indicator. The format string is %b (as in boy) for a binary string. As I said, this should be the value for the format string input. You can right click on the Scan From String and select Edit Scan String. This will bring up a dialog box in which you pick what you want to do (Scan Number) and how you want to do it (Scan Binary Integer
    It sounds like you really need to take a course in LabVIEW programming. There are are links here to NI classes and some on-line tutorials.

  • Key figure Date in Decimal format

    Hi all,
       I have a key figure 0CPR_ACFR_K  (Date) which is in Decimal format.
       Data in PSA for the particular field was like this '07102008'
       but after that it is changing to 7327.98  that is in decimal format.
       But i dont want this to happen ie. it should not get converted to Decimal or
       i want to convert the decimal value again to the equivalent date.
       pls help in this.

    Hi  jean liker,
    It will get converted due to its properties. If you want to use this particular object as keyfigure, you can create a variable with processing type replacement path and use. Its better to maintain as char.
    [Replacement Path: Replacement with a Characteristic Value|http://help.sap.com/saphelp_nw04/helpdata/en/03/6ba03cc24efd1de10000000a114084/frameset.htm]
    Hope it Helps
    Srini

  • Loading the data from a packed decimal format file using a sql*loader.

    Hi ,
    In one of the project i'm working here i have to load the data into oracle table from a file using a Sql*loader but the problem is the data file is in the packed decimal format so please let me know if there is any way to do this....I search a lot regarding this ..If anybody faced such type of problem ,then let me the steps to solve this.
    Thanks in advance ,
    Narasingarao.

    declare
    f utl_file.file_type;
    s1 varchar2(200);
    s2 varchar2(200);
    s3 varchar2(200);
    c number := 0;
    begin
    f := utl_file.fopen('TRY','sample1.txt','R');
    utl_file.get_line(f,s1);
    utl_file.get_line(f,s2);
    utl_file.get_line(f,s3);
    insert into sampletable (a,b,c) values (s1,s2,s3);
    c := c + 1;
    utl_file.fclose(f);
    exception
    when NO_DATA_FOUND then
    if utl_file.is_open(f) then utl_file.fclose(f); ens if;
    dbms_output.put_line('No. of rows inserted : ' || c);
    end;SY.

  • Convert a String to Decimal Format in European format

    Hi Experts,
    I am having a string as a context type for a input field, where the user can enter the Price, I need to convert the same into European format "###.###,00", I am using this below code to convert the string to decimal format
    User will enter the input as 10 as it needs to be converted into 10,00. Also, 1000 which has to be converted as 1.000,00
    String Str1 = wdContext.currentvn_temptable.getVa_TempUnitPrice();
    Locale mylocale  = Locale.GERMAN;
    String pattern="###.###,00";                    
    NumberFormat nf = NumberFormat.getNumberInstance(mylocale);
    DecimalFormat df = (DecimalFormat)nf;
    df.applyPattern(pattern);
    String output = df.format(Str1);
    wdComponentAPI.getMessageManager().reportSuccess("Unit Price" + " " + pattern + " " + output);
    When I execute the above code, i am getting an error called "Malformed Pattern ###.###,00"
    Please let me know, how to convert a String to Quantity in European format
    Thanks & Regards,
    Palani

    Hello!
    Try to change your pattern to this one 
    Locale mylocale  = Locale.GERMAN;
    String pattern = "#,#00.00";                    
    NumberFormat nf = NumberFormat.getNumberInstance(mylocale);
    DecimalFormat df = (DecimalFormat)nf;
    df.applyPattern(pattern);
    String output = df.format(1111111.222);
    Pattern has an influence on number of digits between separators, but you have to use ',' for grouping and '.' for decimal. Character values for separators correspond to your Locale object.
    Thanks, Mikhail

  • Decimal format time value to convert into time (hr:min:sec)value in a graph

    I need to develop a graph in WAD, in BW7. In the graph the value must be showed as HR:MIN:SEC, which I cannot get it right.
    The keyfigure value  carries the duration(hr:min:sec) in decimal format.  In the query, I use this keyfigure for calculation. To get the time broadcasted for a week range. I get the total duration (say 507835.000). Now I need to convert this value back to hr:min:sec. I use the below formulas to get the hr, min, sec.
    D = 507835
    Val1 = D/3600
    Val2 = Frac(val1)
    Val3 = Val2 * 60
    Val4 = frac(Val3) * 60
    Hr = Val1 – Val2
    Min =  Val3 – frac(Val3)
    Sec =  Val4
    In another formula in the query I add Hr + Min/100 + Sec/10000 to get hr.minsec format.
    When I do an average on count of weeks,  this doesn’t round off correctly.
    I tried to also use the Data function TIME() which when the time is > 24 hrs changes the value.
    Lets say if it is 39:00:00, it shows value as 15:00:00 instead of keeping the value 39:00:00.
    When I used this value in the graph it did not show the HR:MIN:SEC values in the value axis instead  it showed 0.0, 0.1,….1.0. Bcoz of this the graph is blank.
    Can anybody help me to resolve this problem.
    Thanks alot
    Anima

    I checked SU01 and didn't see anything there to customize...
    In my workstation, control panel / regional and languages settings / tab regional Options / customize; my time format is HH:mm:ss; the HH has to be in capital letter to display the time in 24 hour...
    but this is strange anyway... are you reporting with web frontend or excel?

  • DBMS_XMLSave.insertXML Fails on decimal format

    DBMS_XMLSave.insertXML Fails on decimal format
    The following example fails when using collections of complex elements. The error is:
    java.lang.NumberFormatException: 1.0'
    Example is:
    create table test_parent(p_id NUMBER(18),
    test_col number(10))
    alter table test_parent add constraint pk1 primary key(p_id)
    create table test_child(t_id NUMBER(18),
    test_col number(10),
    p_id NUMBER(18))
    alter table test_child add constraint pk2 primary key(t_id)
    alter table test_child add constraint fk1 foreign key (p_id) references test_parent(p_id)
    insert into test_parent values(1,1)
    insert into test_child values(1,1,1)
    insert into test_child values(2,2,1)
    insert into test_child values(3,3,1)
    create type test_c AS OBJECT (t_id NUMBER(18),test_col NUMBER(10));
    CREATE OR REPLACE TYPE test_cs AS TABLE OF test_c
    CREATE OR REPLACE VIEW test_view(parent_id,parent_num,child)
    AS SELECT p.P_id,
    p.test_col,
    CAST(MULTISET(SELECT c.t_id,
    c.test_col
    FROM test_child c
    WHERE p.p_id = c.p_id) AS test_cs) AS child
    FROM test_parent P
    CREATE OR REPLACE TRIGGER test_trig INSTEAD OF INSERT ON test_view
    BEGIN
    DBMS_OUTPUT.PUT_LINE('Trigger proccessing');
    END;
    SHOW ERRORS
    DECLARE
    insCtx DBMS_XMLSave.ctxType;
    rows number;
    xmlDoc CLOB := '<ROWSET>
    <ROW>
    <PARENT_ID>2.0</PARENT_ID>
    <PARENT_NUM>2.0</PARENT_NUM>
    <CHILD>
    <T_ID>1.0</T_ID>
    <TEST_COL>1.0</TEST_COL>
    </CHILD>
    </ROW>
    </ROWSET>';
    BEGIN
    insCtx := DBMS_XMLSave.newContext('TEST_VIEW');
    rows := DBMS_XMLSave.insertXML(insCtx,xmlDoc);
    DBMS_XMLSave.closeContext(insCtx);
    END;
    DECLARE
    insCtx DBMS_XMLSave.ctxType;
    rows number;
    xmlDoc CLOB := '<?xml version="1.0"?>
    <ROWSET>
    <ROW>
    <PARENT_ID>1</PARENT_ID>
    <PARENT_NUM>1</PARENT_NUM>
    <CHILD>
    <TEST_C>
    <T_ID>1.0</T_ID>
    <TEST_COL>1</TEST_COL>
    </TEST_C>
    <TEST_C>
    <T_ID>2</T_ID>
    <TEST_COL>2</TEST_COL>
    </TEST_C>
    <TEST_C>
    <T_ID>3</T_ID>
    <TEST_COL>3</TEST_COL>
    </TEST_C>
    </CHILD>
    </ROW>
    </ROWSET>';
    BEGIN
    insCtx := DBMS_XMLSave.newContext('TEST_VIEW');
    rows := DBMS_XMLSave.insertXML(insCtx,xmlDoc);
    DBMS_XMLSave.closeContext(insCtx);
    END;

    If you have access to ON, check out document 119140.1.
    Apparently it's a bug in the jdbc driver in pre-Oracle 8.1.7 databases...the workaround looks messy though.

  • Decimal Format and Scientific Notation

    I am trying to print numbers in scientific notation using the Decimal Format class. What follows is a simple test program I wrote to find the bug. So far, I have not found a solution.
    import java.text.*;
    public class formatted {
    public static void main (String Arguments[]) {
    DecimalFormat form = new DecimalFormat("0.###E0");
         double numb = 123456.789;
         System.out.println("Nuber is: " +
    form.format(numb));
    The output of this program is... Nuber is: 123456E
    The output is the same if numb is an int, float, or double. If I format the number as "#####.0" or "#####.00" the output is correct. I think that I am following the rules for formatting a number in scientific notation as the process is outlined in the documentation (provided below).
    ***** From Decimal Format under Scientific Notation ***
    Numbers in scientific notation are expressed as the product of a mantissa and a power of ten, for
    example, 1234 can be expressed as 1.234 x 10^3. The mantissa is often in the range 1.0 <= x < 10.0,
    but it need not be. DecimalFormat can be instructed to format and parse scientific notation only via a
    pattern; there is currently no factory method that creates a scientific notation format. In a pattern,
    the exponent character immediately followed by one or more digit characters indicates scientific
    notation. Example: "0.###E0" formats the number 1234 as "1.234E3".
    Anyone understand how the short program is incorrectly written?
    Marc

    The problem is
    format = "0.###E0"
    input number = 123456.789
    output = 123456E (not scientific notation!)
    This is not scientific notation at all. There is no decimal point given and no value in the exponent.
    I understand entirely that by adding more #'es will provide more precision. The bug I have is the output is not printed in the scientific format; other formats work.
    MArc

  • Time format to Decimal format

    Hi all
    Does anyone know how to format time format to decimal number?
    Eg: '10:21' in HH24:MI to 10.21
    '21:09' to 21.09
    Thanks in Advance
    Prash

    Since you just want to replace the colon with a period in a string, just use the string replace function:
    select replace('10:21',':','.') from dual;However if you convert this to a number, then as Boneist said it's not really comparable to the time portion of a date as 21 minutes is not 21/100 of an hour but is rather .35 hours (21/60). You won't be able to use this decimalized format as a meaningful number, nor will you be able to do any sort of date based arithmatic on it.
    You may be better off converting your string to date, then into a number via some date math:
    with sample_data as (select to_date('11:21','HH24:MI') dt from dual)
    select dt, (dt - trunc(dt))*24 from sample_data;Edited by: Sentinel on Nov 10, 2008 9:40 AM

  • Property to set hex/binary/decimal format at run time?

    Hi, I'd like to allow my user to choose between hex/binary/decimal formats in his number input. I'm happy to do the radio button stuff and the code to "hear" what he wants, but I can't find a property of my variable which selects the format at run-time - there is of course the "Format & Precision..." which I can get at by right mouse click BEFORE running, so I know it's likely to be available at run-time. Any suggestions welcome. Thanks, Richard.

    It's not necessary to use property node because you can use the builtin
    property of the indicator.
    Click the rigth mouse button over the indicator and select show radix.
    On the left side of the indicator appear radix that you can push to choose
    between hex, binary, octal and decimal.
    Bye
    Golzio
    "R" ha scritto nel messaggio
    news:[email protected]..
    > Hi, I'd like to allow my user to choose between hex/binary/decimal
    > formats in his number input. I'm happy to do the radio button stuff
    > and the code to "hear" what he wants, but I can't find a property of
    > my variable which selects the format at run-time - there is of course
    > the "Format & Precision..." which I can get at by right mouse click
    > BEFORE run
    ning, so I know it's likely to be available at run-time. Any
    > suggestions welcome. Thanks, Richard.

  • Use of comma decimal format in % Breakdowns

    Hello,
    We have global users who would like to enter their decimal values for % Formulation and/or Ranges on the %Breakdowns in the comma decimal format (i.e. 9,99).  This does not seem possible regardless of free text language.  I just wanted to confirm that this was the case.
    Thanks,
    Drew

    Dear Kai,
    Thank you for your reply.
    I read the note and found that if I change my browser language to EN,
    everything works fine.
    However, if I change back my browser language to Chinese,
    the decimal seperator becomes comma.
    In the note 1064448, it said it's related to country settings.
    And the note gave a XML code to set the language to EN.
    But...if I put this code to my WAD XHTML,
    does that mean my chart's related settings, like axis label,
    would also change to English format?
    (Because when I change my browser language to EN, the chart's axis label and some other description also change to EN.)
    Is there any way that I can set the log on language Chinese should use decimal seperator "." instead of ","?

Maybe you are looking for

  • OIM 11g Peoplesoft Roles provisioning issue

    Hi All, We have configured Peoplesoft Connector 9.1.1.6 to provision roles to Peoplesoft through access policy. We are not able to provision multiple roles into Peoplesoft. It just provisions first role to user in peoplesoft and errors when provision

  • Problem removing children from within an event handler

    I'm trying to remove a movie clip from an onComplete handler. When I try to do this I get the following error "ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller." The point where my loader is complete is the time th

  • Wont complie..

    i just want a txtarea in the middle and a bunch of menu action but i keep error and i dont see why C:\Documents and Settings\Administrator\Desktop\menu.java:60: illegal start of expression      public void actionPerformed(ActionEvent e)      ^ C:\Doc

  • UnsatisfiedLinkError and Java Virtual Machine error

    Hi, I'm trying load a library using the following lines: static {      System.loadLibrary("mtcokus.dll"); System.out.println("Random generator DLL loaded"); I'm getting the following error in the console: java.lang.UnsatisfiedLinkError: no mtcokus.dl

  • Importing Widget - Menubar 2.0 - Help!

    I went to widget browser, and to adobe exchange where I formatted Spry Horizontal MenuBar 2.0 exactly how I wanted it...saved it to my presets. (It showed up on the adobe exchange horizontally like I wanted it. Then I opened a page in dreamweaver CS5