Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to identify whether the data has been changed in ALV or not

Former Member
0 Kudos

Hello All,

How to identify whether the data has been changed in ALV or not

Regards,

Lisa

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hello,

What do you want to do?

To refresh the whole table at the end(method CHECK_CHANGED_DATA of CL_GUI_ALV_GRID) or make a check on the cell just after the change (react to event handle_data_changed)?

Regards,

Walter

7 REPLIES 7

Former Member
0 Kudos

Hi,

Use the system field SY-DATAR for check whether there is a change in the screen or not.

If you want to check based on the records compare the internal table.

Reward if helpful.

Former Member
0 Kudos

Hello,

What do you want to do?

To refresh the whole table at the end(method CHECK_CHANGED_DATA of CL_GUI_ALV_GRID) or make a check on the cell just after the change (react to event handle_data_changed)?

Regards,

Walter

0 Kudos

Hello Walter,

I have given ALV in the editable mode. So i want to check whether the data has been changed or not.

If checked i will do some process.

Regards,

Lisa.

0 Kudos

Hello Lisa,

In OO case:

after creating your ALV, you have first to register to teh 'ENTER' event: everytime the user press enter, the event will be triggered:


CALL METHOD gr_alv->register_edit_event
      EXPORTING
        i_event_id = cl_gui_alv_grid=>mc_evt_enter.

Then you have to create the event handler:


CREATE OBJECT gr_alv_handler_1100.
    SET HANDLER gr_alv_handler_1100->handle_data_changed FOR gr_alv.

An example of handler class:


CLASS lcl_alv_handler_1100 DEFINITION.                          "#EC CLAS_FINAL
  PUBLIC SECTION.
    METHODS:
      handle_data_changed                                       "#EC CALLED
         FOR EVENT data_changed OF cl_gui_alv_grid
             IMPORTING er_data_changed,
ENDCLASS.               "LCL_ALV_HANDLER_1100

In the par er_data_changed, you can see which cells have been modified and check the new values.

Hope this help,

Walter

0 Kudos

Excellent. It works know.

former_member194669
Active Contributor
0 Kudos

Hi,

Check this


    call function 'REUSE_ALV_GRID_DISPLAY'
      exporting
        it_fieldcat                 = pt_grpfcat[]
        it_excluding                = p_grpexcltab2[]
        is_layout                   = pt_grplayout2
        i_callback_program          = sy-repid
        i_callback_html_top_of_page = p_header
        i_callback_pf_status_set    = v_status_set1
        i_callback_user_command     = v_user_command1
        i_screen_start_column       = 25
        i_screen_start_line         = 5
        i_screen_end_column         = 80
        i_screen_end_line           = 20
        it_events                   = i_events[]
      tables
        t_outtab                    = i_grpoutput.
  else.
    message i367(yscc) with v_plgrp..
  endif.
endform.                                 " F_f4_help_fieldname
*
*&---------------------------------------------------------------------*
* Form  f_user_command1                                                *
*&---------------------------------------------------------------------*
* This form will handle the user command from fm REUSE                 *
*----------------------------------------------------------------------*
form f_user_command1 using p_ucomm type sy-ucomm
                     rs_selfield type  slis_selfield.

  data p_ref1 type ref to cl_gui_alv_grid.
  call function 'GET_GLOBALS_FROM_SLVC_FULLSCR' "<< check this
    importing
      e_grid = p_ref1.
  call method p_ref1->check_changed_data. "<< check this
  case p_ucomm.
    when 'YCNC'.
      leave to screen 0.
    when 'YNTR'.
      perform f_upload_regions.
      leave to screen 0.
    when 'YSEL'.
      perform f_select_deselect_all using c_x.
    when 'YDEL'.
      perform f_select_deselect_all using space.
  endcase.
  rs_selfield-refresh = c_x.             " Grid refresh

endform.                                 " F_user_command1
*

aRs

Message was edited by:

0 Kudos

Sorry i forgot to mention at the begining that i a usiing OOPS concept to dispaly and edit ALV