Skip to Content
author's profile photo Former Member
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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    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)&

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    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.

    Add a comment
    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 06, 2010 at 10:39 AM

    Thank you

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.