09-01-2008 12:41 PM
Hi to all
i have quantity field, i want to get(display) decimals values if present other wise i need to get with out decimals(only numeric).
supposy my field is w_bstmg
if i have value in w_sub_bstmg 445.50
i have to display 445.50
if i have value in w_sub_bstmg 445.00
i have to display 445
i am able to display with the following code upto 1000.
DATA: l_bstmg TYPE i,
l_bstmg_1 TYPE rkwa-wrbtr.
DATA: w_sub_bstmg TYPE rkwa-bstmg,
w_bstmg_1 TYPE char17.
IF w_sub_bstmg < 0.
w_sub_bstmg = ABS( w_sub_bstmg ).
l_bstmg = w_sub_bstmg MOD 10000.
IF l_bstmg < w_sub_bstmg.
w_bstmg_1 = w_sub_bstmg.
ELSE.
w_bstmg_1 = l_bstmg.
ENDIF.
CONCATENATE w_bstmg_1 '-' INTO w_bstmg_1.
ELSE.
l_bstmg = w_sub_bstmg MOD 10000.
IF l_bstmg < w_sub_bstmg.
w_bstmg_1 = w_sub_bstmg.
ELSE.
w_bstmg_1 = l_bstmg.
ENDIF.
ENDIF.
if i have value more than 1000 in w_sub_bstmg then how to get it.
is there any FM to find decimals position, if so can any body help me
09-01-2008 12:51 PM
Hi use this way ...it can do
DATA: ulimit type p decimals 2 VALUE '12.00'.
DATA: STR(10) TYPE C.
DATA: FINAL(10) TYPE C.
DATA: LEN TYPE I.
DATA: LEN1 TYPE I.
STR = ULIMIT.
CONDENSE STR.
IF STR CA '.'.
LEN = SY-FDPOS.
ENDIF.
LEN1 = LEN + 1.
IF STR+LEN1(2) = '00'.
FINAL = STR+0(LEN).
WRITE: FINAL.
ELSE.
WRITE: ULIMIT.
ENDIF.
cheers
Suku
09-01-2008 12:59 PM
Hi.. Radha...
Excute this program once
And Use this logic to solve your problem...
data: dec1 type p decimals 2,
bal like <Amount field>.,
int(10) type n.
parameter: p_bal like <Amount field>.
bal = p_bal.
dec1 = frac( bal ).
int = trunc( bal ).
if dec1 ne '.00'.
write:/ bal.
else.
write:/ int. <---- Here yo can avoid two write statements with concatinating dec1 and int into other variable
endif.
Thanks,
Naveen.I
09-01-2008 1:24 PM
Use this ....
temp = w_sub_bstmg * 100 . " decimals will be moved right side of the "."
temp = temp mod 100 . " Again get last two places of number , means decimal portion from w_sub_bstmg
if temp is not initial.
w_sub_bstmg = w_sub_bstmg / 100. " if no decimal places found
endif.
hope it helps ....
10-31-2008 1:49 PM