ABAP Blog Posts
cancel
Showing results for 
Search instead for 
Did you mean: 

As we know, when we change any entry in the ALV grid from CL_GUI_ALV_GRID, event DATA_CHANGED will be triggered, and we can do some custom validation checks there.

However, you may have faced this situation, after you change the ALV and push on some user command, like 'ZSAVE' or 'SAVE', the DATA_CHANGED event will not be triggered again, because no cell is changed in ALV grid. And actually, you want to trigger it and do same check or other validations.

This blog will show you how to do it with real-time example.

1. Let's create a class for our Z-program  as below.

Surendra_Karma_0-1791446285832.png

2. To call the ALV grid,  method SET_TABLE_FOR_FIRST_DISPLAY has been called and ENTER event has been registered.

Surendra_Karma_1-1791446380183.png

3. The VALIDATION_CHECK is a method that we have linked to ENTER event for event handling.

Surendra_Karma_2-1791446462511.png

4. Now, the real-catch is when we call a custom function code e.g. ZSAVE, we take any column of ALV grid and put all ALV table entries for that column as a a DELTA modification cell.
Thereafter, if we call CHECK_CHANGED_DATA method, our VALIDATION_CHECK method will get triggered.

Surendra_Karma_4-1791446798474.png

I have gone through multiple similar blogs, but those were not helpful. Somewhere calling CHECK_CHANGED_DATA is written or somewhere forcefully setting 'GridModified' = '1' with SET_PROP has been used or somewhere something else. But unfortunately, inside VALIDATION_CHECK, changed data entries are not reflecting in GOOD_CELLS or MOD_CELLS to validate.

So, I thought to share this knowledge to our community. This is tried and tested method, which seems to be more aligned with ALV modification protocols.

Happy learning!

2 Comments
Labels in this area