Skip to Content
avatar image
Former Member

how to find the number of decimals in a given value

Hi all,

Can u please help me in solving the problem,

i have a value called 5987.45

and decimal places are 45 that is 2 numbers

2) 765.987

number of digits in decimals are 3.

3) 67543.1

number of digits in decimals are 1.

for this i need a coding

thanks.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Jun 23, 2009 at 12:48 PM

    Hi,

    While printing your text element give as;

    &wa_tab-dec_value(.2C)&

    This will always print everything with 2 decimals.

    Regards

    Karthik D

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 23, 2009 at 12:48 PM

    Hi,

    Use the FM SWA_DETERMINE_DECIMALS.

    regards,

    Ankur Parab

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 23, 2009 at 03:56 PM

    HI,

    split your value at '.' into two variables and find the number of characters of the decimal part.

    eg.

    if value = '123.567'.

    split value at '.' into integer_part decimal_part.

    no_of_decimals = numofchar( decimal_part.) .

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 24, 2009 at 01:44 AM

    Hi,

    Use FM SWA_DETERMINE_DECIMALS to calculate the decimal count value.

    Hope this may be useful..

    Regards,

    Prashant

    Add comment
    10|10000 characters needed characters exceeded