Application Development and Automation 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: 
Read only

alv grid update problem

Former Member
0 Likes
661

hi,

i have a method named get_changed_data. it is called when i press enter after i've changed data on alv grid. in method get_changed_data i'm calling a method of cl_gui_alv_grid named check_changed_data for getting updated data. but it goes endless loop ( i guess inside check_changed_data my method get_changed_data is called ). is there an alternative method to get updated data on alv grid

2 REPLIES 2
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
446

Hi,

Refer code:-


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
     i_callback_program                = v_rep_id       " report id
     i_callback_pf_status_set          = 'PF'           " for PF-STATUS
     i_callback_user_command           = 'USER_COMMAND' " for User-Command
     is_layout                         = wa_layout      " for layout
     it_fieldcat                       = it_field       " field catalog
     it_sort                           = it_sort        " sort info
    TABLES
      t_outtab                          = it_final      " internal table
   EXCEPTIONS
     program_error                     = 1
     OTHERS                            = 2.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

*&---------------------------------------------------------------------*
*&      Form  pf
*&---------------------------------------------------------------------*
*       SUB-ROUTINE PF IS USED TO SET THE PF-STATUS OF THE SCREEN
*       ON WHICH THE ALV GRID IS DISPLAYED
*----------------------------------------------------------------------*
*       -->RT_EXTAB
*----------------------------------------------------------------------*
FORM pf USING rt_extab TYPE slis_t_extab.
  SET PF-STATUS 'ZTG_STAT'.
ENDFORM.                    "pf

*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
*       SUB-ROUTINE USER_COMMAND IS USED TO HANDLE THE USER ACTION
*       AND EXECUTE THE APPROPIATE CODE
*----------------------------------------------------------------------*
*      -->LV_OKCODE   used to capture the function code
*                     of the user-defined push-buttons
*      -->L_SELFIELD   text
*----------------------------------------------------------------------*
FORM user_command USING lv_okcode LIKE sy-ucomm l_selfield TYPE slis_selfield.

* assign the function code to variable v_okcode
  lv_okcode = sy-ucomm.

* handle the code execution based on the function code encountered
  CASE lv_okcode.

* when the function code is SAVE then process the selected records
    WHEN 'SAVE'.

* to reflect the data changed into internal table
      DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new

      IF ref_grid IS INITIAL.
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
          IMPORTING
            e_grid = ref_grid.
      ENDIF.

      IF NOT ref_grid IS INITIAL.
        CALL METHOD ref_grid->check_changed_data.
      ENDIF.

* refresh the ALV Grid output from internal table
      l_selfield-refresh = 'X'.

  ENDCASE.

ENDFORM.                    "USER_COMMAND

Refer this wiki code to reflect data changes from alv grid to internal table:-

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/alv%252bgrid%252bdisplay%252bwith%252bch...

Hope this helps you.

Regards,

Tarun

Edited by: Tarun Gambhir on Mar 12, 2009 3:57 PM

Read only

uwe_schieferstein
Active Contributor
0 Likes
446

Hello Deniz

All you need is to call method go_grid->check_changed_data( ) at PAI of your screen. If you do not need any validations then you do NOT need any method to handle event DATA_CHANGED.

For more details please refer to thread

In addition, you may have a look at my remarks about class CL_GUI_CFW in the blog

[A Christmas Collection of Useful Classes|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/12377] [original link is broken] [original link is broken] [original link is broken];

Regards

Uwe