Application Development 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: 

rouding the value for currency data type

Former Member
0 Kudos

HI All,

How to display the integer part of a value if it is of currency data type??

For ex: data: t_val type curr.

t_val = 345.58.

Now I wanted to display the value only 345. How can I do this??

My actual problem is :

In an internal table there is a field with currency data type, I want to display only integer part value of that field, I dont want to display decimal part. How it can be done??

Plz suggest me.

Thanks,

Satish.

7 REPLIES 7

Former Member
0 Kudos

data:t_val1 type p.

t_val1 = t_val.

hymavathi_oruganti
Active Contributor
0 Kudos

CEIL

Smallest integer value that is not less than x

FLOOR

Largest integer value that is not greater than x

TRUNC

Interger part of x

ex:

ceil( x ), floor( x ), trunc( x ).

SPACE IS IMPORTANT

Message was edited by: Hymavathi Oruganti

Message was edited by: Hymavathi Oruganti

0 Kudos

Hi,

I think Ceil, Floor, Trunc works on datatypes I, P, F.

I tried using Trunc, but its not working as the datatype is currency.

rgds,

satish.

0 Kudos

try this..

data : var_char typ c,

var_packed type p.

var_char = var_currency.

var_packed = var_char.

or write var_currency to var_char decimals '0'.

0 Kudos

THEN DECLARE A TYPE OF F, PASS THAT TO THIS

data: C TYPE C,p type F, K TYPE I.

C = '5.5'.

P = C.

P = TRUNC( p ).

K = P.

WRITE K.

IAM AGAIN PASSING IT TO INTEGER TYPE BECAUSE, IF NOT U WILL GET O/P AS 5.00000000000000000000E

if u dont use "trunc" and if decimal is >5 then u will get o/p as 6 instead of 5.

0 Kudos

just copy and paste the code it is running fine...

data: v_typ like vbrk-netwr.

data:v_char(15) type c.

data: v_typ1 type p.

v_typ ='345.67'.

v_char = v_typ.

v_typ = TRUNC( v_typ ).

v_typ1 = v_typ.

write : v_typ1.

former_member181962
Active Contributor
0 Kudos

YOu can use the FM: ROUND

Or the syntax 'FLOOR'.

v_int = floor (v_value).

Regards,

ravi