Converting Decimal Number to Fraction

by Reena

The Function Module CONVERT_TO_FRACTION can be used to convert a decimal number (e.g., 0.145) to a fraction. 

Sample Source Code:

Report sample_test.

* Published at www.SAPTechnical.COM

data: w_nom LIKE T006-ZAEHL.
data: w_den  LIKE T006-NENNR.

CALL FUNCTION 'CONVERT_TO_FRACTION'
EXPORTING
  input = '0.5625'
IMPORTING
  NOMINATOR = nom
  DENOMINATOR = den
* EXCEPTIONS
* CONVERSION_OVERFLOW = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

write: w_nom, '/',  w_den.                                          

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image