Skip to Content
avatar image
Former Member

decimals

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Sep 01, 2008 at 11:51 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 01, 2008 at 11:59 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2008 at 12: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 .... 😊

    Add comment
    10|10000 characters needed characters exceeded