Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

how to delete trailing zeros after decimal ?

Hi,

i want to delete trailing zeros after decimal.

Example:

if it is 22.000 then output will be 22

if it is 22.010 then output will be 22.01.

plz let me know hw to do this ?

Tags:
Former Member
Former Member replied
DATA:
  lv_decimal TYPE f DECIMALS 3,
  lv_string  TYPE string.
 
lv_decimal = '22.010'.
 
WRITE lv_decimal TO lv_string.
SHIFT lv_string RIGHT DELETING TRAILING '0'.

* also delete trailing '.', if possible
SHIFT lv_string RIGHT DELETING TRAILING'.'.
CONDENSE lv_string NO-GAPS.
 
* now no trailing zeros are in the decimal stored in LV_STRING

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question