How to get only two digits after decimal point of an expression
i am doing simple multiplication between two float numbers.
both the numbers have two digits after decimal point.
so naturally the result will have 4 digits after decimal point.
i want to get only two digits after decimal point.
help me please...
If you just want to limit the displayed decimal places, you can do the following...
import java.text.*;
public class Formatting {
public static void main(String[] args) {
NumberFormat format = NumberFormat.getNumberInstance();
format.setMaximumFractionDigits(2); //what you seem to want
format.setMinimumFractionDigits(2); //if you always want at least 2 digits displayed
System.out.println(format.format(12.345));
System.out.println(format.format(12.0));
Similar Messages
-
FM to get only quantity without its decimal points
hi guys,
is there any FM that can enable to get only qty without its decimal points without rounding up.
e.g.: 500.12 , i need to get only 500 and exclude .12Hi Ester,
U dont need any FM for that. You can use a simple logic like shown below:
data: lv_quant TYPE p DECIMALS 3 VALUE '500.96'.
DATA: lv_out type i.
lv_out = trunc( lv_quant ).
write lv_out. "this will have your result
Regards,
Prakash -
Only two figures after the point...
Hi,
I have a float number with 6,7 figures after the point, as I make for have only two figueres after the point??
thanksCheck out the DecimalFormat class
http://java.sun.com/j2se/1.4.2/docs/api/java/text/DecimalFormat.html -
How to get only expanded node after open & close in CL_GUI_ALV_TREE?
Hi,
I have a tree structure using CL_GUI_ALV_TREE.
I would like to capture only the expanded nodes AFTER open and close operation.
If the user opens all the nodes and then closes them, I get all the nodes when using GET_EXPANDED_NODES.
I want to get only the expanded nodes that the user currently sees on the screen (so in open and close you will not get it as open).
whatever I tried doesn't work.
Do you have any idea how to do it?
Thanks,
Itaythis methods calls method of attribute MR_COLUMN_TREE without setting the parameter NO_HIDDEN_NODES to 'X'
that's why you get every node that is "open" even if not "visible"
as this attribute MR_COLUMN_TREE is protected, you cannot access it...
you should consider using an object of class CL_GUI_COLUMN_TREE directly in place of CL_GUI_ALV_TREE so that you can call the method with this parameter set...
you will have far more to do by hand but you will get more flexibility... -
Purchase price to have 4 digits after decimal point
Hi Friends,
Would you please help me out with this issue?
The purchase price needs to have 4 digits after the decimal point, because the product/component would be packed and sold in other unit, which may give huge value difference.
The price can be set for the product/component per 100, but is there any setting in SAP Reference IMG?
Thanks for your help.
Regards,
JTHi,
In material Master (MM01) which unit you maintain for that material. Go to MM02 and keep Base Unit of Measure as storing unit as earlier and maintain Sales unit (unit of measure in which the material is sold) or Order Unit (Specifies the unit of measure in which the material is ordered) in the Purchase Order according to your requirement and Enter the factor for converting the alternative unit to the base unit. In your case product/component would be packed in a Different unit.
OR
In your case product/component would be packed in a Different unit.
Maintain the (BOM) Bill of Material for the finished product you are selling and its component.Create Finished Product as material type as FERT and Components as material type as HALB or ROH.
Now try your transaction with Finished Product only and sale.
Hope the above will help.
Regards,
Biju K -
Number of digits after decimal point.
Hi,
Here is a small program which takes x1 and gives the square root of x1, For e.g for 2 it prints 1.4142135623730951
Suppose I need to have only one decimal place i.e 1.4 then how do I get this.
import java.util.*;
class MySquare {
public static void main(String args[]) {
double x1 = 2;
double x2 = Math.sqrt(x1);
System.out.println("Square root of x1 " + (x2));
Output of this is:
Square root of x1 1.4142135623730951try:
int whole = (int)x2;
int decimal = ((int)(x2*10)) - whole*10;
System.out.println("Square root of x1 " + whole +"."+decimal);p.s. this is untested, but it gives you an idea -
How to get values after decimal point
Hi,
source value is 12345.678 i wana the target side in 12345 in field and 678 in one field.
the source value its not fixed before decimal point value pass to one field and after decimal point value pass to other field
please help to me how to do this one.Hi Swathip,
You dont need to create 2 UDFs. You just need to create 1 simple UDF which takes one string array as input as usual and it has 2 Resultlist outputs. You need to map this 2 outputs from the UDF to the respective 2 target side fields where the values are to be mapped, one containing the portion before the decimal, and one after the decimal.
I HAVE TESTED THE UDF AND IT WORKS ABSOLUTELY FINE.
THE CODE FOR THE UDF IS AS FOLLOWS:
public void sepDec(String[] num,ResultList wholeNum,ResultList afterDec,Container c)
String part1=null; // Stores the part before the decimal point
String part2=null; //Stores the part after the decimal point
if(num[0]!=null && num[0]!=""){
int index = num[0].indexOf(".");
part1 = num[0].substring(0,index);
part2=num[0].substring(index+1, num[0].length());
wholeNum.addValue(part1);
afterDec.addValue(part2);
THIS UDF IS A CLASSIC EXAMPLE WHERE AN UDF HAS 2 OUTPUTS, WHICH IS VERY RARELY SEEN BUT VERY MUCH CORRECT
PLEASE LET ME KNOW IF THIS CODE WAS HELPFUL TO YOU
CHEERS,
BISWAJIT
Edited by: 007biswa on Feb 8, 2011 5:02 PM -
I do not have an option to join tracks in Itunes 11.2.2.3. My options button has only two choices after selecting multiple tracks - get track names and submit cd track names. How do I join multiple tracks into one?
Weird, works for me.
tt2 -
How to remove zero after decimal point.
hi friends
how to remove the zero after decimal points.
example :
123.450 -- if print only 123.45
45.600 - 45.6
any body help me.
thanks
pauldhamago through this example
it may help u
DATA: T(14) VALUE ' abcdefghij',
STRING LIKE T,
STR(6) VALUE 'ghijkl'.
STRING = T.
WRITE STRING.
SHIFT STRING LEFT DELETING LEADING SPACE (or use 0 to detete 0).
WRITE / STRING.
STRING = T.
SHIFT STRING RIGHT DELETING TRAILING STR or 0.
WRITE / STRING.
Output:
abcdefghij
abcdefghij
abcdef -
In Table Control How to get only a single row .
Hi
In Table Control How to get only a single row .I am able to decrease it its height to 4 but then 2 rows is getting dsplayed .I want only one row to be display and 2nd row should be deactivated or not visible.
regards
Avik
Edited by: Julius Bussche on Jan 30, 2009 1:10 PM
Removed friendly greeting from the subject titleHi Avik
use this code it will help you.
MODULE passdata OUTPUT.
READ TABLE it_revision INTO wa_rev INDEX tab_clc-current_line.
IF sy-subrc = 0.
LOOP AT SCREEN.
IF screen-group1 = '111'. " 111 IS THE GROUP NAME
screen-input = 1. " input mode
screen-active = 1. " input mode.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ELSE.
LOOP AT SCREEN.
IF screen-group1 = '111'. "GROUP NAME
screen-input = 0. " display mode
screen-active = 1. " DISPLAY MODE.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
ENDMODULE. " PASSDATA OUTPUT
Make sure in group tou are passing the field name that you want in input mode on the base of other field
Hope it will help you.
Thanks
Arun Kayal. -
How to get number of digits in given amount
Hi Experts,
How to get number of digits in given amount.
Regards
MohitCheck this :
data: v_data1 type p decimals 3 value '12.860',
v_char1 type char20,
v_char2 type char20,
v_char3 type char20,
len type i.
write v_data1 to v_char1.
split v_char1 at '.' into v_char2 v_char3.
len = strlen( v_char3 ).
write:/ v_char2,
/ v_char3, " this holds the digit value
/ len. " number digits -
How to get only current exception message from tables
Hi
In my sceanario , I want to have the list of Current MRP exception messages list from table
I understand that MRP detailed lists, including all exception messages, are stored in transparent table MDKP and cluster table MDTC.
I can tell ABAPer to write a report for me , to read the data from these tables , but I guess these tables contain old exception message also , which are not currently appearing in MRP list
How to get only current exception message
Rgds,
sandeepSandeep,
MDTC contains only data from the most recent MRP run. So, all messages you see are those which are currently valid.
The messages might have first appeared during a previous run, but they still need to be addressed.
Before you invest a lot of time and effort into writing and debugging a custom report, you should probably try to use the standard SAP functionality found in MD06. On the Processing indicator tab, you can select "Only with new exceptions". Here you can tag a material/plant as 'processed', and thereafter, the exceptions that existed there before you tagged the part will not be re-displayed.
Best Regards,
DB49 -
How to get temperature from digital camera in to controller
how to get temperature from digital camera in polarising microscope using t95 controller without adc.dll
Ask the manufacturer of your camera…
What kind of answer do you expect? -
How to get only the first result in extract function
do you know how to get only the first element of the function extract.
v_result := p_response.doc.extract('//'||p_name||'/child::text()').getstringval();
if i have 5 responses like '100','100',100','200','200' e get '100100100200200' and i want only '100'.
thanks in advanceTwo ways .....
1. Use Javascript E4X instead ...there are nice functions for getting children of parents.
2. Cycle through all of the form1.nodes and look for objects that have a className of "subform". For loops are useful for this task.
Make sense?
Paul -
Any idea how to get Yahoo to load after installing Mountain Lion??
http://www.koingosw.com/support/wiki/index.php/General_FAQ#Uninstalling_and_Pref erence_File_Locations
Maybe you are looking for
-
How does 'Multiple Calendar Option' work in 7.9.6
Friends, Could some one please explain me what this 'Multiple Calendar' option is, in 7.9.6. There is not much Information in Config guide with this regard. My Question is, does 'Multiple Calendar option' means 7.9.6 supports different calendars but
-
Adobe Flash Player Installer freezes
Hi, im trying to download the newest version of Adobe flash and the installer keeps freezing. my browser is Firefox but its the newest version of it and iv tried other browsers and nothing changes. this is a brand new PC that i just got yesterday so
-
Im from Spain, but If Im in US and I buy the new Iphone 5, I dont know If later I could use it normally in Spain? There are some problems now? Or forever? Thanks
-
1180: Call to a possibly undefined method box.
So I have my class being called on the main timeline var test:box = new CustomBoxThing(); //or var test:MovieClip = new CustomBoxThing(); //then test.name = "someName1"; addChild(test); And its not working so well for me, I keep getting error 1180. I
-
SQL Fails when a division is included in query (in Java Code)
Not sure this is the correct Forum to as this: Running Oracle 10g R2 on XP/Vista I have a query that contains a division operation (y.value as x.value/z.value) runs in SQLPlus and The NetBeans 6.5.1 Query Editor OK but when I insert it into Java (1.6