 Former Member

# How can i remove zeros after the Decimal

Data : G_SUM TYPE p DECIMALS 5.

I am doing calculation and the value of G_SUM will be 20.00000

Now, my requirement is : -

Can i remove all the zeros after the decimal.

If the G_SUM value is 20.23000

Now, it should become : -

20.23

Any suggestino will be appreciated!

Regards,

Kittu

10|10000 characters needed characters exceeded

### Related questions Former Member
Posted on Mar 29, 2010 at 11:23 AM

Data : G_SUM TYPE p DECIMALS 5 VALUE 20.00000.

Data: G_OUT type p decimals 2.

move g_sum to g_out.

write g_out.

that should do it.

or if you need it in a form you could as well use &G_SUM(.2)&

10|10000 characters needed characters exceeded
• Former Member
Posted on Mar 29, 2010 at 11:33 AM

Hi!!

In which format u are displaying ur output. i.e list , alv or smartform. and at which level u want to removes the decimal points.

if at start level than as u told above keep decimals to two. if u want to keep decimal 5 and want to show two, than plz tell in which format ur output is coming.

10|10000 characters needed characters exceeded
• Posted on Mar 29, 2010 at 04:11 PM

Hi Kittu,

i assume, you want to get rid of trailing zeros for output purpose.

So this is the code for it.

```DATA: l_tx_number TYPE c LENGTH 15.
DATA: l_sign.
WRITE g_sum TO l_tx_number RIGHT-JUSTIFIED.
* take care of the sign
SHIFT l_tx_number RIGHT CIRCULAR.
l_sign = l_tx_number(1). CLEAR l_tx_number(1).
SHIFT l_tx_number RIGHT DELETING TRAILING '0'.
* restore the sign
l_tx_number(1) = l_sign.
SHIFT l_tx_number LEFT CIRCULAR.
```

regards

Jörg

10|10000 characters needed characters exceeded
• Former Member
Posted on Jul 06, 2010 at 10:39 AM

Thank you