Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Caluculation

Former Member
0 Likes
549

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.

4 REPLIES 4
Read only

Former Member
0 Likes
520

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

Read only

Former Member
0 Likes
520

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.

Read only

Former Member
0 Likes
520

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

Read only

Former Member
0 Likes
520

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