Retrun the fraction / whole value of a decimal number using MOD, DIV, FRAC or SHIFT

Below is a list of ABAP coding examples of how to return just the fraction/whole section of a decimal number such as 1.3456

DATA: ld_decimal TYPE P DECIMALS 4 VALUE '1.3456',
        ld_fraction TYPE P DECIMALS 4,
        ld_fracstr TYPE string,
        ld_whole    type i.
* Display full number with fraction
  WRITE:/ 'Full number =', ld_decimal.
* Get the whole number
  ld_whole = ld_decimal DIV 1.
  WRITE:/ 'Whole section =', ld_whole.
* Get the fraction value of number using MOD
  ld_fraction = ld_decimal MOD 1.
  WRITE:/ 'Fraction =', ld_fraction.
* Get the fraction value of number using FRAC
  ld_fraction = FRAC( ld_decimal ).
  write:/ 'Fraction =', ld_fraction .
* Get the fraction value of a decimal number using string manipulation
  ld_fracstr = ld_decimal.
  shift ld_fracstr LEFT up to '.'.
  shift ld_fracstr LEFT by 1 places.
  write:/ 'Fraction =', ld_fracstr .


Related Articles

Data manipulation - Example code and information on various data manipulation techniques
Remove spaces from character field (CONDENSE)
Move minus sign(-) from end to start of field
ABAP Round functionality to round values down to nearest value based on your decimal place requirement
Round ABAP values up to the nearest value
Inserting TAB's into text strings
Change characters within a string ( TRANSLATE )