02-09-2010 10:14 AM
Hi,
I'm using an editable ALV to display the output. Output has a field for the user to enter comments. When the user enters the comments and presses "ENTER" key or clicks somewhere else on the ALV itself, the event DATA_CHANGED or DATA_CHANGED_FINISHED gets triggered and I'm able to capture the changed data and update the DB table.(I have a "SAVE" button on the menu bar which when pressed will update the ALV values into DB table.)
However, I need to capture this changed data even if the user does not press the "ENTER" key or clicks somewhere else on the ALV, but just presses the "SAVE" button. Please let me know if there is any way to do this.
Thanks,
Raj.
02-09-2010 10:22 AM
Hi,
in your program check the user-command if 'SAVE' then write the following code in it
"Call the method check_changed_data to update the internal table with changed data.
DATA: lv_valid TYPE xfeld,
lv_refresh TYPE xfeld.
CALL METHOD gv_alv_grid->check_changed_data
IMPORTING
e_valid = lv_valid
CHANGING
c_refresh = lv_refresh.
" to refresh alv
CALL METHOD gv_alv_grid->refresh_table_display
EXCEPTIONS
finished = 1
OTHERS = 2.
by this way it the internal table will get the changed data and then you can update it in the DB and also after updating show the ALV since it is refreshed it will now show the changed data.
Hope it helps you,
Regards,
Abhijit G. Borkar
02-09-2010 10:22 AM
Hi,
in your program check the user-command if 'SAVE' then write the following code in it
"Call the method check_changed_data to update the internal table with changed data.
DATA: lv_valid TYPE xfeld,
lv_refresh TYPE xfeld.
CALL METHOD gv_alv_grid->check_changed_data
IMPORTING
e_valid = lv_valid
CHANGING
c_refresh = lv_refresh.
" to refresh alv
CALL METHOD gv_alv_grid->refresh_table_display
EXCEPTIONS
finished = 1
OTHERS = 2.
by this way it the internal table will get the changed data and then you can update it in the DB and also after updating show the ALV since it is refreshed it will now show the changed data.
Hope it helps you,
Regards,
Abhijit G. Borkar
03-31-2011 1:18 PM
Hi Lakshmiraj,
I am facing same problem. can you please let me know what was the solution for the same ?
Regards,
Kunjan
03-31-2011 1:53 PM
Hi,
my favorite way is to activate extra events for edit mode
* ENTER key is pressed or
CALL METHOD go_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
* data is changed and cursor is moved from the cell
CALL METHOD go_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
Have a look here for a complete example:
[http://www.kerum.pl/infodepot/00006|http://www.kerum.pl/infodepot/00006]
Cheers,
Kris
04-01-2011 3:49 AM
Hello Laxmi,
You can use the method check_changed_data from class cl_gui_alv_grid in the PAI of your Save button or can check upon user commande for "SAVE" and then refresh your table grid disaply and all the updated data will be there in your internal table and from that you can then update your database table.
Data: grid TYPE REF TO cl_gui_alv_grid,
l_valid TYPE char1,
CALL METHOD grid->check_changed_data
IMPORTING
e_valid = l_valid.
IF l_valid IS NOT INITIAL.
*l_valid not initial means data has been changed.
CALL METHOD grid->refresh_table_display
EXCEPTIONS
finished = 1
OTHERS = 2.
*This method will refresh ALV display on screen.
ENDIF.
Hope this helps!
Regards,
MBD