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: 

Updating Z table according ALV rows

Former Member
0 Kudos
917

Hi All!

I'm updating several columns automatically in ALV grid rows into Z database (current user name, date and hour). However, when I change only one row, all existed rows on the list are updated.

How can I update only the changed data in ALV?

ps.: it's used REUSE_ALV_GRID_DISPLAY FM.

Points will be rewarded!

Michel Khouri

1 ACCEPTED SOLUTION

former_member194669
Active Contributor
0 Kudos
127

Hi,

May this way.


    i_backupoutput[] = i_grpoutput[]. " <<< copy output table to temp table

    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.

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'
    importing
      e_grid = p_ref1.
  call method p_ref1->check_changed_data.
  case p_ucomm.
    when 'SAVE'.
      loop at i_grpoutput.
        read table i_backupoutput index sy-tabix.
        if sy-subrc eq 0.   
        if i_grpoutput ne i_backupoutput.
          <<<<<<< Update the record to Z table>>>>>>>>>  
 
        endif. 
        endif.
      endlloop.
      leave to screen 0.
 
  endcase.
  rs_selfield-refresh = c_x.             " Grid refresh

endform.                                 " F_user_command1

aRs

Message was edited by:

3 REPLIES 3

former_member393151
Participant
0 Kudos
127

My thought is that you would have to keep a "before" copy of the table. Loop through the before - and if the same row on the after is not the same - update this row.

Former Member
0 Kudos
127

Hi,

Before displaying store the output internal table in a temporary internal table..

Then before updating the Z table..Check the output internal table with the temporary internal table..if there is any change in the row..then update that row..otherwise don't update ..

Thanks

Naren

former_member194669
Active Contributor
0 Kudos
128

Hi,

May this way.


    i_backupoutput[] = i_grpoutput[]. " <<< copy output table to temp table

    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.

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'
    importing
      e_grid = p_ref1.
  call method p_ref1->check_changed_data.
  case p_ucomm.
    when 'SAVE'.
      loop at i_grpoutput.
        read table i_backupoutput index sy-tabix.
        if sy-subrc eq 0.   
        if i_grpoutput ne i_backupoutput.
          <<<<<<< Update the record to Z table>>>>>>>>>  
 
        endif. 
        endif.
      endlloop.
      leave to screen 0.
 
  endcase.
  rs_selfield-refresh = c_x.             " Grid refresh

endform.                                 " F_user_command1

aRs

Message was edited by: