Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

suppress zeros after decimal point

Former Member
0 Kudos

Hi,

If my quantity field only have zeros after decimals then i want to suppres the zeros after decimal point when displaying the values in alv.

How can i do that?

My field is of type QUAN 13(3) in database.

Please help..

6 REPLIES 6

former_member404244
Active Contributor
0 Kudos

Hi,

U can split the value of the filed at decimal point..

split var at '.' into var1 var2.

var = var1.

Regards,

Nagaraj

0 Kudos

Hi Nagraj,

In run-time SAP takes the value as 123.000 if the value of that field is 123.

Split doesnot help here i suppose.

0 Kudos

Hi,

In that case u can put a check

clear : var1.

split var at '.' into var1 var2.

if var1 is not initial.

var = var1.

endif.

now the var will be correct value even though it doesn't have zero's, if it has zeros after the decimal as we are using split it will have the value before the decimal..

Hope it helps.

Regards,

Nagaraj

Former Member
0 Kudos

You need to simply assign the quan field to an integer field.

Check this.

DATA: a TYPE p DECIMALS 2 VALUE '123.00',
      b TYPE i.
b = a.
WRITE: a, b..

0 Kudos

Hi Nitesh,

in this case, no values will be displayed even there are valid values after decimal.

i want to suppres if there are only zeros after decimal point.

0 Kudos

you just have to check if the integer value is equal to the original (if yes, that means there were no decimals)

<spoonfeeding>

DATA: a TYPE p DECIMALS 2 VALUE '123.00',
      b TYPE i.
b = a.
IF a = b.
WRITE: a, b.
ENDIF.

</spoonfeeding>

(For the ones who suggested SPLIT: it is not possible to split numeric data types, you have to move the value to character type first.)