Application Development and Automation 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: 
Read only

About decimals

Former Member
0 Likes
628

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
604

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.

5 REPLIES 5
Read only

Former Member
0 Likes
604

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

Read only

Former Member
0 Likes
604

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.

Read only

Former Member
0 Likes
604

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

Read only

Former Member
0 Likes
605

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.

Read only

Former Member
0 Likes
604

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!!!