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: 

Refresh Data REUSE_ALV_GRID_DISPLAY

Former Member

Dear all

I have an ALV grid using REUSE_ALV_GRID_DISPLAY and I change data during execution.

How can I now force the refresh of the grid? (Can I for example force myself the use of the standard refresh button)

I tried for ex.

FORM user_comm USING l_ucomm LIKE sy-ucomm l_selfield TYPE slis_selfield.

PERFORM update_alv_tab.

endform.

FORM update_alv_tab .

DATA : e_grid TYPE REF TO cl_gui_alv_grid.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = e_grid.

CALL METHOD e_grid->check_changed_data.

"update_alv_tab

CALL METHOD e_grid->refresh_table_display.

ENDFORM. " UPDATE_ALV_TAB

it seems to work on debug, but when i start my program normal, it closes SAP Gui with an error message!!!! not bad.

Any other ideas ?

Herbert

1 ACCEPTED SOLUTION

venkat_o
Active Contributor

Herbert, Try this way.


*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
 FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE SLIS_SELFIELD.
  IF R_UCOMM = 'REFRESH'."Create one button on ALV toolbar with function code REFRESH
    RS_SELFIELD-REFRESH = 'X'. "Set this one. It refreshes internal table data with new values
  ENDIF.
ENDFORM.                    "USER_COMMAND
Thanks Venkat.O

11 REPLIES 11

venkat_o
Active Contributor

Herbert, Try this way.


*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
 FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE SLIS_SELFIELD.
  IF R_UCOMM = 'REFRESH'."Create one button on ALV toolbar with function code REFRESH
    RS_SELFIELD-REFRESH = 'X'. "Set this one. It refreshes internal table data with new values
  ENDIF.
ENDFORM.                    "USER_COMMAND
Thanks Venkat.O

Former Member
0 Kudos

I want to do it automatically. There is already the standard Refresh Button. But I don't want the user to press it

0 Kudos

Hi,

Just check the code of the standard refresh, if possible , you can copy and paste the same subroutine when you require refresh to be happened.

Former Member

Hi,

Why dont you try like this:



FORM user_comm USING l_ucomm LIKE sy-ucomm l_selfield TYPE slis_selfield.
l_SELFIELD-REFRESH = 'X'.
endform.

Regards,

Himanshu

0 Kudos

This also closes my SAP Gui

Former Member
0 Kudos

Hi,

Use this.

DATA:

lv_ref_grid TYPE REF TO cl_gui_alv_grid.

CLEAR : gv_tcode.

*-- to ensure that only new processed data is displayed

IF lv_ref_grid IS INITIAL.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = lv_ref_grid.

ENDIF.

IF NOT lv_ref_grid IS INITIAL.

CALL METHOD lv_ref_grid->check_changed_data.

ENDIF.

THis will solve your problem.

Regards,

Vijay

0 Kudos

The big problem seems to be that it works on debug when i put a break-point on it, but it closes my SAP Gui when I do not debug !!!!!!!!!!!!! Really strange

0 Kudos

Found it. I had to replace my perform which fills the internal table and now it works. No idea, why it shot me before

thank you all

0 Kudos

I know this is old...

i had the same issue with updating a alv (when a user puts in new data) from within REUSE_ALV_GRID_DISPLAY fm. in the i_callback_user_command form, i put in the fm get_globals_from_slvc_fullscr with the e_grid = grid (defined in the form as type ref to cl_gui_alv_grid) and then the two call methods, grid->check_changed_data and grid->refresh_table_display. this worked like a charm.

thanks for all the help above.

Yes this code script is excellent when need to refresh table data and insert new one. Thanks for question and answers, this made my day today. 😃

0 Kudos

Thanks Guys.Very Helpful code.Works to get changed data from ALV into user command. I had to set layout_h-sel_mode = 'D' for capture mutliple rows in REUSE_ALV_GRID_DISPLAY_LVC.