Hi Experts,
I'm having a problem with decimal.
I have a alv data grid that can be edited.Once I press enter the value for the decimal fields are changed.
Example: If i input 5.00 in the field then I press enter it converts it to 0.05
And If I input 2.01 in the field it shows an error Too many decimal places(Maximum 0)
DATA INPUT for my internal table:
DATA: BEGIN OF it_data OCCURS 0,
docno LIKE zit_haul_line-docno,
line LIKE zit_haul_line-line,
eqpno LIKE zit_haul_line-eqpno,
rpt LIKE zit_haul_line-rpt,
notrip LIKE zit_haul_line-notrip,
trc LIKE zit_haul_line-trc,
escfee LIKE zit_haul_line-escfee,
tollfee LIKE zit_haul_line-tollfee,
repr LIKE zit_haul_line-repr,
others LIKE zit_haul_line-others,
tba LIKE zit_haul_line-tba,
dik LIKE zit_haul_line-dik,
locorg LIKE zit_haul_line-locorg,
locdes LIKE zit_haul_line-locdes,
END OF it_data.
DATA: wa_data LIKE it_data.
Here is my code in change ALV Change.
FORM data_changed USING ir_data_changed TYPE REF TO cl_alv_changed_data_protocol.
DATA ls_modi TYPE lvc_s_modi.
DATA: ratepertrip LIKE zit_haul_line-rpt,
nooftrip LIKE zit_haul_line-notrip,
lv_value TYPE lvc_value ,
totalrent LIKE zit_haul_line-trc,
escortfee LIKE zit_haul_line-escfee,
tollfee LIKE zit_haul_line-tollfee,
represent LIKE zit_haul_line-repr,
others LIKE zit_haul_line-others,
lv_value1 TYPE lvc_value,
totalbill LIKE zit_haul_line-tba.
DATA: eqpno LIKE equi-equnr,
gv_equnr LIKE equi-equnr.
* Check each modification:
LOOP AT ir_data_changed->mt_mod_cells INTO ls_modi.
CASE ls_modi-fieldname.
WHEN 'EQPNO'.
CONDENSE ls_modi-value.
SELECT SINGLE equnr
INTO gv_equnr
FROM equi
WHERE equnr EQ ls_modi-value.
IF sy-subrc NE 0.
CALL METHOD ir_data_changed->add_protocol_entry
EXPORTING
i_msgid = '00'
i_msgty = 'E'
i_msgno = '398'
i_msgv1 = 'Equipment Number does not exist:'
i_msgv2 = ls_modi-value
i_msgv3 = ''
i_msgv4 = ''
i_fieldname = ls_modi-fieldname
i_row_id = ls_modi-row_id.
ENDIF.
ENDCASE.
CALL METHOD ir_data_changed->get_cell_value
EXPORTING i_row_id = ls_modi-row_id
i_fieldname = 'RPT'
IMPORTING e_value = ratepertrip.
CALL METHOD ir_data_changed->get_cell_value
EXPORTING i_row_id = ls_modi-row_id
i_fieldname = 'NOTRIP'
IMPORTING e_value = nooftrip.
CLEAR totalrent.
ls_modi-fieldname = 'TRC'.
IF ratepertrip = ''.
ratepertrip = 1.
ELSEIF nooftrip = ''.
nooftrip = 1.
ENDIF.
totalrent = ratepertrip * nooftrip.
CALL METHOD ir_data_changed->modify_cell
EXPORTING i_row_id = ls_modi-row_id
i_fieldname = ls_modi-fieldname
i_value = totalrent.
CALL METHOD ir_data_changed->get_cell_value
EXPORTING i_row_id = ls_modi-row_id
i_fieldname = 'ESCFEE'
IMPORTING e_value = escortfee.
CALL METHOD ir_data_changed->get_cell_value
EXPORTING i_row_id = ls_modi-row_id
i_fieldname = 'TOLLFEE'
IMPORTING e_value = tollfee.
CALL METHOD ir_data_changed->get_cell_value
EXPORTING i_row_id = ls_modi-row_id
i_fieldname = 'REPR'
IMPORTING e_value = represent.
CALL METHOD ir_data_changed->get_cell_value
EXPORTING i_row_id = ls_modi-row_id
i_fieldname = 'OTHERS'
IMPORTING e_value = others.
CLEAR totalbill.
ls_modi-fieldname = 'TBA'.
totalbill = escortfee + tollfee + represent + others.
totalbill = totalrent + totalbill.
CALL METHOD ir_data_changed->modify_cell
EXPORTING i_row_id = ls_modi-row_id
i_fieldname = ls_modi-fieldname
i_value = totalbill.
ENDLOOP.
ENDFORM. "data_changed