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.

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

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.

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 🙂

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.