Wednesday 26 March 2014

How to convert floating value ( 4.4000000000000000E+01 ) to char value ( 44 )

In our development we often came across many situation where we need to convert floating value to char value for example to display the value at the output of ALV .


REPORT  ztestr_2.

DATA lv_value_from TYPE atflv VALUE '4.4000000000000000E+01',
       lv_output     TYPE cha_class_view-sollwert.

CLEAR lv_output.

CALL FUNCTION 'QSS0_FLTP_TO_CHAR_CONVERSION'
  EXPORTING
    i_number_of_digits   2
    i_fltp_value         lv_value_from
    i_screen_fieldlength 16
  IMPORTING
    e_char_field         lv_output.

WRITE /  lv_output.

output :  44.00

NB : The exporting parameter ' i_number_of_digits ' determines the number of digits after decimal which are visible.
if you write i_number_of_digits = 1 ,
output will be 44.0