01-14-2009 1:29 PM
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..
01-14-2009 1:33 PM
Hi,
U can split the value of the filed at decimal point..
split var at '.' into var1 var2.
var = var1.
Regards,
Nagaraj
01-14-2009 1:38 PM
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.
01-14-2009 2:05 PM
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
01-14-2009 1:41 PM
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..
01-14-2009 1:53 PM
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.
01-14-2009 2:07 PM
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.)