10-22-2009 7:55 AM
Hi All,
I have a alv program using OOPS concept where two fields(columns) are editable in the alv output. These two columns contain table names and field names which can be edited.
I just want to validate these table and field names when we press the save button. If the edited entry is valid,i.e., the tablename is existing in the database, then it must update the entered value oftbl name to the db. else it shud give a error msg.
Please help with this code.
Thanks in Advance.
10-22-2009 8:08 AM
10-22-2009 8:07 AM
Hey!!!
Try using this...
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS : handle_data_changed FOR EVENT data_changed
OF cl_gui_alv_grid
IMPORTING er_data_changed.
ENDCLASS.
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
PERFORM data_changed USING er_data_changed.
ENDMETHOD.
ENDCLASS.
form DATA_CHANGED using p_er_data_changed
TYPE REF TO cl_alv_changed_data_protocol.
DATA : ls_mod_cells TYPE lvc_s_modi,
declare a variable for your table or field name.
LOOP AT p_er_data_changed->mt_good_cells INTO ls_mod_cells.
CASE ls_mod_cells-fieldname.
WHEN 'LIFNR'.
CALL METHOD p_er_data_changed->get_cell_value
EXPORTING
i_row_id = ls_mod_cells-row_id
i_fieldname = 'LIFNR'
IMPORTING
e_value = The variable you have defined.
put ur condition according to variable here, if the condition is not satisfied, then throw a message like this.
CALL METHOD p_er_data_changed->add_protocol_entry
EXPORTING
i_msgid = 'ZFI'
i_msgno = '999'
i_msgty = 'E'
i_msgv1 = 'Employee Number Doesn''t Exist'
i_fieldname = ls_mod_cells-fieldname
i_row_id = ls_mod_cells-row_id.
EXIT.
ENDIF.
.
Hope this helps.
Regrds,
Abhinab Mishra
12-25-2013 2:37 PM
Thanks Abhinab,
your answer helped me to solve similar issue i was facing.
10-22-2009 8:07 AM
Hi Aishwarya ,
You can use the below code at the starting of SAVE button press, to get the latest changes made on ALV into your internal table,
* Logic to get the latest output of the grid into internal table
DATA: ref_grid TYPE REF TO cl_gui_alv_grid.
IF ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref_grid.
ENDIF.
IF NOT ref_grid IS INITIAL.
CALL METHOD ref_grid->check_changed_data .
ENDIF.
going further you can validate the column fields values !!
Edited by: Salil Jha on Oct 22, 2009 9:07 AM
10-22-2009 8:08 AM
10-23-2009 12:58 PM