Skip to Content

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

图像 001.png

2.Run your program and update data, then save.

图像 007.png

图像 010.png

3.Push ‘SAVE’, event will be triggered.

图像 003.png

图像 004.png

This is my first time to write blog, please give your comment if you also have some experience on this topic. Thanks.

To report this post you need to login first.

11 Comments

You must be Logged on to comment or reply to a post.

  1. Swadhin Ghatuary

    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.

    (0) 
  2. Matija Liber

    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.

    (0) 
  3. Sandra Rossi

    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)

    (0) 
    1. Łukasz Pęgiel

      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.

      (0) 
      1. Sandra Rossi

        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 🙂

        (0) 

Leave a Reply