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: 

About: Auto refresh the ALV report display

former_member789579
Discoverer
0 Kudos

Hi @Eitan,

I used your code(below) in my report for refreshing alv grid, I think it works, the records in the grid are being updated but the old records are still in the grid, I mean in each update operation ,the modified records are getting , my problem is that old records are also getting.

Please let me know a possible solution.

Regards,


CLASS: cl_event_receiver DEFINITION DEFERRED.

DATA: ob_event_receiver TYPE REF TO cl_event_receiver.

DATA: ob_gui_timer TYPE REF TO cl_gui_timer .

Class handler:
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
CLASS cl_event_receiver DEFINITION .


METHODS: finished
FOR EVENT finished OF cl_gui_timer .

ENDCLASS . "cl_event_receiver DEFINITION
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
CLASS cl_event_receiver IMPLEMENTATION.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
METHOD finished .

CHECK p_tmr_on EQ abap_true .

ob_gui_timer->cancel( ) .
ob_gui_timer->interval = p_tmr_in .
ob_gui_timer->run( ) .

* Your code to load the alv data .
PERFORM get_data_1 .

LEAVE TO SCREEN 100 .

ENDMETHOD. "finished
*----------------------------------------------------------------------*
ENDCLASS . "cl_event_receiver IMPLEMENTATION

Selection screen:

*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK block12 WITH FRAME .
PARAMETERS: p_tmr_on TYPE timer_on AS CHECKBOX ,
p_tmr_in TYPE timer_i DEFAULT 60 OBLIGATORY .
SELECTION-SCREEN END OF BLOCK block12.
*----------------------------------------------------------------------*

At pbo (after the ob_gui_alv_grid->set_table_for_first_display):

IF ob_gui_timer IS INITIAL .
CREATE OBJECT ob_gui_timer .
SET HANDLER ob_event_receiver_1->finished FOR ob_gui_timer .
ENDIF .

* Start timer .
IF p_tmr_on EQ abap_true .
ob_gui_timer->interval = p_tmr_in .
ob_gui_timer->run( ).
ENDIF.

1 REPLY 1

Sandra_Rossi
Active Contributor

You are showing the code of the CL_GUI_TIMER handler, but not how you handle the ALV grid contents.

Anyway, you are using LEAVE TO SCREEN 100, but you don't need to leave a screen to go to another screen, you need to refresh the contents of the ALV grid control, i.e. you only need to call alv_grid->refresh_table_display( ).

PS: please use the CODE button to format the lines of code.