2007 Aug 29 12:00 PM
Hi all,
i have an value like this
say 10.77 or 10 or 12.56
i just want to check whether decimal places are there or not.
for eg 10.77 has decimal places but 10 dont have
points will be rewarded
thanks in advance
2007 Aug 29 12:11 PM
You could use the expression FRAC which seperates the decimal part of a number.
data w_dec(2) type p.
data my_number(12) type p decimals 2.
W_DEC = FRAC( MY_NUMBER ).
IF W_DEC IS INITIAL.
I have a whole number, as the part after the . is 0
ELSE:
I have a decimal as the part after the . contains a number.
ENDIF.
Hi all,
i have an value like this
say 10.77 or 10 or 12.56
i just want to check whether decimal places are there or not.
for eg 10.77 has decimal places but 10 dont have
points will be rewarded
thanks in advance
2007 Aug 29 12:05 PM
Hi,
Move that field to a charecter type field, then use the SEARCH option for the DOT(.) then if the sy-subrc is equal to 0 then the field is having the DOT
regards
Sudheer
2007 Aug 29 12:08 PM
Hi,
Select all the amounts seperated with dots..
data: amount(15) type c value '200,000,000.000'.
while sy-subrc = 0.
replace '.' with space into amount.
endwhile.
condense amount no-gaps.
write:/ amount.
2007 Aug 29 12:10 PM
data: lv_swap type c length 12.
lv_swap = yournumber.
find '.' in lv_swap.
if your sy-subrc = 0 then it contains a dot, if sy-subrc = 4 it doesnt.
Message was edited by:
Florian Kemmer
2007 Aug 29 12:11 PM
You could use the expression FRAC which seperates the decimal part of a number.
data w_dec(2) type p.
data my_number(12) type p decimals 2.
W_DEC = FRAC( MY_NUMBER ).
IF W_DEC IS INITIAL.
I have a whole number, as the part after the . is 0
ELSE:
I have a decimal as the part after the . contains a number.
ENDIF.
2007 Aug 29 1:33 PM
REPORT ZTRIP_TEST.
data:
p1 like bseg-dmbtr,
temp like p1.
p1 = 10.
temp = p1 mod 1 .
if temp eq 0.
write:/ p1,' does not have decimal value'.
else.
write:/ p1,' has decimal value',temp.
endif.
p1 = '10.26'.
temp = p1 mod 1 .
if temp eq 0.
write:/ p1,' does not have decimal value'.
else.
write:/ p1,' has decimal value',temp.
endif.
Reward points if useful, get back in case of query...
Cheers!!!
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |