04-14-2008 3:24 PM
Hello.
I'm using an ALV display with a custom field catalog to allow a user to edit data via the ALV display (certain fields).
I create my container and fieldcatalog in the PAI of my screen and use CALL METHOD grid1->refresh_table_display to display it, I can edit the contents of the table displayed in the ALV just fine. I can validate each entry the user makes using the register_edit_event and use CALL METHOD er_data_changed->get_cell_value to get the user data as they enter and I can then validate the entry against my custom rules. My issue is that if the user violates the rules I defined in my code I would like to reset the entry. What method can I use to do this. My code for validation is below.
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
DATA: ls_good TYPE lvc_s_modi.
DATA wa LIKE LINE OF lt_good_cells.
CALL METHOD grid1->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
LOOP AT er_data_changed->mt_good_cells INTO ls_good.
v_tabix = sy-tabix.
CASE ls_good-fieldname.
WHEN 'QUANTITY'.
CALL METHOD er_data_changed->get_cell_value
EXPORTING
i_row_id = ls_good-row_id
i_fieldname = 'MATNR'
IMPORTING
e_value = v_1303matnr.
CALL METHOD er_data_changed->get_cell_value
EXPORTING
i_row_id = ls_good-row_id
i_fieldname = ls_good-fieldname
IMPORTING
e_value = v_qtytemp.
*---> I validate here and if I find an issue I would like to reset or change the cell value.
ENDCASE.
ENDLOOP.
ENDMETHOD.
Thanks!!
04-14-2008 7:31 PM
Try this way
if v_error_flag = 'Y'. " Found error during validation
call method g_grid->refresh_table_display.
else.
call method g_grid->check_changed_data
importing
e_valid = v_valid.
endif.
a®
04-14-2008 9:39 PM
If I'm not mistaken wouldn't call method g_grid->refresh_table_display refresh the entire table? I was looking to simply refresh the entry that was edited (the entire row if necessary).
04-22-2008 7:54 PM
I have located the answer.
When I do my validation routine if my error criteria has been reached I through a flag and then execute the method "modify_cell" to reset it to whatever value I choose.
CALL METHOD er_data_changed->modify_cell
EXPORTING
i_row_id = ls_good-row_id
i_fieldname = <my fieldname>
i_value = <value to reset field to>.