SAP ABAP: Converting a floating point number to a packed field

In some cases we need to convert float values. Here’s a simple example.

DATA :
lv_in TYPE atflv VALUE ‚2.1000000000000000E+01‘,
lv_out     TYPE cha_class_viewsollwert.

CLEAR lv_out.
CALL FUNCTION ‚QSS0_FLTP_TO_CHAR_CONVERSION‘
EXPORTING
i_number_of_digits   2
i_fltp_value         lv_in
i_screen_fieldlength 16
IMPORTING
e_char_field         lv_out.
WRITE /  lv_out.

output :  21.00