Skip to Content
0

Removing decimal points from a currency value

Oct 18, 2016 at 06:02 AM

199

avatar image
Former Member

Dear experts,

I have a variable of type HSLXX12. I need to round and remove the decimal points in the value. I could round the value using the ROUND function as following.

result = ROUND( val = input dec = 0 )

Then I used TRUNC to remove decimals. But it is not working. How can I remove the decimals?

If the value is 173645.00 I want to display it as 173645

Is it possible to do this, without changing the data type? Please help.

Thanks in advance.

Manori

10 |10000 characters needed characters left characters exceeded
Former Member

Hello Manori,

The solution;

DATA:  lv_decimal TYPE p DECIMALS 2,

       lv_string  TYPE string.

lv_decimal = '22.00'.

lv_string = ROUND( val = lv_decimal dec = 0 ).

0
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Raymond Giuseppi
Oct 18, 2016 at 06:09 AM
1

This value is a Currency field, so its display is controled by the currency code, so answer could be 'no' you cannot. You should so change to some other type or use a currency without decimal positions (browse table TCURX) There are some tricks but they depend on where you want to display the amount: dynpro field, alv, sap script, smartforms, adobe, etc.

Regards,
Raymond

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thank You, Raymond for the quick response.

I need to display in a smart form. If I change the data type, then I will have to do a big change.

If there is some other way, can you please post it.

Thanks.

0

Smartforms has such Output Options for Field Contents, like &field(.0)&.

Regards,
Raymond


1
Kali Charan Oct 18, 2016 at 06:55 AM
0

Why don't you use String in Smart form.You can do the below task in Smartform coding part else in driver program.
DATA:net TYPE ekpo-netpr VALUE '2500.00',
c1 TYPE string.

WRITE:net.
c1 = trunc( NET ).
"MOVE net TO c1.
WRITE:c1.

Share
10 |10000 characters needed characters left characters exceeded