Trigger ALV data_change event manual
As we know, when we changed something in the alv grid, event data_changed will be triggered, and we can do some custom check.
but do you face this situation, after you changed this alv and push on some user command, like ‘SAVE’, the data_changed event will not be triggered again, because no cell is changed in alv grid, but actually, you want to trigger it and do something you want.
below i will give you 1 solution to trigger it by compulsion.
in PAI, use method IF_CACHED_PROP~SET_PROP of class CL_GUI_ALV_GRID to set property ‘GridModified’ as modified, then call CHECK_CHANGED_DATA of CL_GUI_ALV_GRID, data_changed event will be triggered.
1.add code in PAI
2.Run your program and update data, then save.
3.Push ‘SAVE’, event will be triggered.
This is my first time to write blog, please give your comment if you also have some experience on this topic. Thanks.
Good.. Thanks for Sharing...
It is very helpful to me and beginners.Thank you very much for sharing.
Keep going on..All the best
Hello Aiolos ,
Thanks a lot for this blog, it not only save time but also a good trick to trigger the data_change event manually. one more thing i want to add that i use this event in classical alv to find out data in editable alv grid is changed or not. i add the code with hope it will help other
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_repid = sy-repid
e_grid = it_grid.
CALL METHOD it_grid->check_changed_data
IMPORTING
e_valid = p_valid.
if P_VALID = 'X'.
now you add your custom task to be done if data changed.
Yes, swadhin.
Thanks to Reply, this will be useful for FM ALV.
Thanks a lot!
Hi Aiolos,
Is good post, but one thing You miss. 😉
We called pv_grid->check_changed_data -> the event data_change is trigger and data are changed. After this must call again IF_CACHED_PROP~SET_PROP of class CL_GUI_ALV_GRID with PROPNAME = 'GridModified' and set PROPVALUE = '0'.
If we will not set PROPVALUE to zero the ALV instance will be always in modified mode and for every action( for example : click on button, etc..) will trigger the DATA_CHANGE event.
Cheers.
I'm curious to know what is the interest of triggering manually the DATA_CHANGED event? (I've written many editable ALV grids, and I think I explored almost all possible functions, seen many issues, but I never needed to trigger it manually)
In most cases I also don't see a need for that but I faced a situation when users wanted to be allowed to enter anything into grid and at save function they wanted to get all errors. In this case manuall triggger suits well.
Thanks! It's good to know a situation for which it can be used 🙂 I had found a solution with the standard events to put aside the messages, so the user was not bothered with the popup at every invalid cell, and he/she could also see his erroneous entries while typing, but well, that would be another discussion 🙂
If it is still possible can you give more information about your solution ?
Create a docking container where to display the log, and during the event DATA_CHANGED, call the method ER_DATA_CHANGED->DISPLAY_PROTOCOL to indicate the log container. You should also initiate the ALV grid by calling the method GRID->ACTIVATE_DISPLAY_PROTOCOL( 'X' ) to avoid the focus moving from the ALV grid to this log container.
Triggering manually the DATA_CHANGED event has been used by some developers to manage the following situation :
Examples of thread :
Thanks for sharing
Thanks a lot
Thank you , unfortunately when you forced to triiger the event mt_mod_cells has no values. How will you identify the modified cells instead of selecting all records to increase performance of it?