‎2006 Sep 25 7:39 AM
How do i remove the decimals from a variable?
If I have 40.587, I want it to become 40. And no rounding off.
‎2006 Sep 25 7:40 AM
Hi,
Move the value to the variable of type P and display it.
Regards,
Senthil
‎2006 Sep 25 7:42 AM
data: f1 type p decimals 3 value '40.002'.
data:f2 type p.
f2 = f1.
write:f2.
‎2006 Sep 25 7:43 AM
hi ,
declare the variable as type p decimals 0,
i think this will helpful.
thank.
‎2006 Sep 25 7:47 AM
I already did not using type p with or without decimals. But if I have 40.587 it will assign 40857 to the variable. Im getting the 40.587 from a table.
‎2006 Sep 25 7:53 AM
Hi Adrian,
Just goto the table name, then goto the field, double click the data element, then double click the domain. Check if there is any conversion routine for the field, if it exist double click that and use the FM in ur program.
Like this.
**CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v1
IMPORTING
OUTPUT = v3
.
*write 😕 v3.
The 'ALPHA_INPUT' should be the convers exit in the domain of your field.
Reward if helps.
Regards,
Senthil
Message was edited by: senthil kumar
‎2006 Sep 25 7:47 AM
hi,
where ever you are outputting your value, add NO-DECIMALS NO-GAP,
cheers,
Aditya.
‎2006 Sep 25 7:47 AM
Use the FM : HR_IN_ROUND_AMT
eXPORTING
AMOUNT : 40.587
RNDOFF : 100
RMDLMT : L
‎2006 Sep 25 7:47 AM
hi,
data var1 type p decimals 3 value '20.455'.
data var2 type i.
move var1 to var2.
write : / var2. " 20
reward if useful...
‎2006 Sep 25 7:54 AM
I already did that. Using type I, but it just eliminates the period and put them all in the variable.
From 40.587 to 40587.
This is kinda weird...
‎2006 Sep 25 7:58 AM
Hi Adrian,
Did you try using the FLOOR function?
Regards,
Saurabh
‎2006 Sep 25 8:02 AM
Yes. I also use the floor function. the decimals keeps sticking to the value. Let's say 40.587, it becomes 40587.
‎2006 Sep 25 8:04 AM
one another concern:
<b>in that program attributes, check the field <u>FIXED POINT ARITHMETIC</u> is selected or not.
this check box should be selected,to get the exact values.</b>
REPORT ZSRIM_TEMP25.
data : v_p(12) type p decimals 3,
v_i type i.
v_p = '123.456'.
v_i = floor( v_p ).
v_i = trunc( v_p ).
write 😕 v_i.
you can use either FLOOR or TRUNC in this case,both will return numeric part of your variable to V_I.
here for both options,i am getting 123 to V_I variable.
Regards
srikanth
Message was edited by: Srikanth Kidambi
‎2006 Sep 25 8:13 AM
Hi Adrian,
In the Program attributes please check the checkbox 'Fixed Point Arithmetic'.
This should solve your problem (along with using the FLOOR function).
Hope this helps!
Regards,
Saurabh
‎2006 Sep 25 7:53 AM
Hi Adrian,
You can use the FLOOR function.
eg.
DATA : w_num type p decimals 3 value '40.587',
w_num_i type i.
w_num_i = FLOOR( w_num ).
Now w_num_i will contain 40.
Hope this helps!
Regards,
Saurabh
‎2006 Sep 25 8:12 AM
as Srikanth pointed out in ur program
goto>attributes> check Fixed point arithmetic,
<b>Fixed point arithmetic</b>
If you mark this checkbox, all caluculations in the program will use fixed point arithmetic.
If you do not, packed numbers (ABAP/4 type P, Dictionary types CURR, DEC or QUAN) will be treated as integers when they are used in assignments, comparisons and calculations, irrespective of the number of decimal places defined. Intermediate results in arithmetic calculations will also be rounded to the next whole number. The number of decimal places defined is only taken into account when you output the answer using the WRITE statement.
this will work
REPORT ZSPELL.
data : v_amt type p decimals 2 value '40.58',
v_int type i.
v_int = floor( v_amt ).
write : v_int.Message was edited by: Chandrasekhar Jagarlamudi
‎2006 Sep 25 8:13 AM