Skip to Content

How can i remove the zero from decimal ?

Dear Guru ,

I am writing an abap program and i want to remove all zero from decimal side .

For instance :

DATA : L_A TYPE MENGE VALUE '333.000' .

DATA : L_A TYPE MENGE VALUE '3335.300' .

.....

.....

OUTPUT :
333
3335.3

Is it possibile to do that ?

Thanks .

Best Regards,

Carlos Zhang

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 08, 2010 at 10:33 AM

    the easiest way tould be define the variable with the TYPE of a field for which such conversion routine is already defined. conversion routines are assigned at the domain level. the other obvious way is through coding.

    Check function modules CONVERSION_EXIT_*

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 08, 2010 at 08:30 AM

    You can use TRANSLATE or SHIFT statement to remove the zeros

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 08, 2010 at 08:57 AM
    DATA : l_a TYPE p LENGTH 13 DECIMALS 3 VALUE '333.000' .
    DATA : l_b TYPE p LENGTH 13 DECIMALS 3 VALUE '3335.300' .
    DATA : l_ax(14).
    DATA : l_bx(14).
    
    l_ax = l_a.
    l_bx = l_b.
    
    CONDENSE: l_ax, l_bx.
    
    SHIFT: l_ax RIGHT DELETING TRAILING space,
           l_bx RIGHT DELETING TRAILING space,
           l_ax RIGHT DELETING TRAILING '0',
           l_bx RIGHT DELETING TRAILING '0',
           l_ax RIGHT DELETING TRAILING '.',
           l_bx RIGHT DELETING TRAILING '.'.
    
    CONDENSE: l_ax, l_bx.
    
    WRITE: l_ax, / l_bx.
    
    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.