‎2007 Dec 20 11:20 AM
Hi,
I have internal table field of type vbdpr-ntgew.
The value of that variable at run time is 1,143.060 now what I need to do I need to display only integer part in my smart form.
I mean in above if decimal part is greater than 500 I need to display next rounded value in my smart form I mean 1144 in above example other wise I need to display 1143. And the value I need to display in system user setting format.
And my internal table contains one more field that is for total and I am calculating total based on the below formula
Total = above value (1143) * price.
Price contains value 100,00
So my output coming 114300,000
But I want to display only two decimals in total but I am taking brgew as reference to that internal table field. I can not change the reference fields in my internal table fields.
Please help me. I will give points.
Thanks a lot in advance.
‎2007 Dec 20 11:29 AM
For rounding off you can move vbdpr-ntgew field value to a numeric field.
Declare a field
Data: ntgew(13) type n.
Move vbdpr-ntgew to ntgew. "rounded off value.
For removing an extra decimal:
Write Total to Itab-total decimals 2.
Lokesh
‎2007 Dec 20 11:35 AM
Hi,
You can use floor and ceil in your program for rounding off the decimals. Below is the example code you can use :
DATA: I TYPE I,
P TYPE P DECIMALS 2,
M TYPE F VALUE '-3.5',
D TYPE P DECIMALS 1.
P = ABS( M ). " 3,5
I = P. " 4 - business rounding
I = M. " -4
I = CEIL( P ). " 4 - next largest whole number
I = CEIL( M ). " -3
I = FLOOR( P ). " 3 - next smallest whole number
I = FLOOR( M ). " -4
I = TRUNC( P ). " 3 - integer part
I = TRUNC( M ). " -3
D = FRAC( P ). " 0.5 - decimal part
D = FRAC( M ). " -0.5
Thanks,
Sriram Ponna.
‎2007 Dec 20 11:37 AM
Hi,
U have declare the variable as type p(for ur numeric variable)
To get only two decimals after the numbers
give as
Type: ...........decimals 2
To remove commas use the statement NO-GROUPING...it will remove the commas,,
Regards,
Ari
‎2007 Dec 20 11:38 AM
Use the command Ceil or Floor based on the decimal value .....if it is less than 5 ie .5 use ceil or else floor ...so that u can round off.............