02-19-2010 10:09 AM
Hi ,
I have developed a report using REUSE_ALV_GRID_DISPLAY function module. The input of the report is date, so as the time changes the output changes, means for the same date input the out put will changes as time of execution changes.
There is a refresh button in the tool bar. The user wants to click the refresh button and the data should automatically change.
I have used the function module as shown below.
Display ALV list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_repid
i_callback_pf_status_set = g_form_set_pf_stat
is_layout = l_wa_layo
it_fieldcat = l_t_fcat
i_save = 'A'
it_events = l_t_evts1
is_print = l_wa_prnt
TABLES
t_outtab = g_t_mpoints
EXCEPTIONS
program_error = 1
OTHERS = 2.
Can you help in refresh of data when the user clicks on refresh button.
Thanks,
Prem.
02-19-2010 10:11 AM
in pf_status
check sy-ucomm if refresh(function code)
your output table is g_t_mpoints
if any select query directly filling that dtable or any process ..call them again in refresh
02-19-2010 10:12 AM
Hi,
I would rather suggest you use the OO method of displaying the Grid.
Use the class cl_gui_alv_grid
There are a lot methods that will suit your requirement.
02-19-2010 10:19 AM
Hi Prem,
ALV is the type of display in which changes in the database can not be automatically refreshed.
so if you want to display the data on a particular time, you need to fetch the data once again and call the FM again. as suggested, depending on the sy-ucomm variable you cna fetch the latest data once again and display in the ALV.
I am not sure if there is any method available directly for refreshing the ALV o/p in OOPS.
Thanks,
Teja.
02-19-2010 10:26 AM
Hi,
Refer below code:-
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid " report id
i_callback_pf_status_set = 'PF' " for PF-STATUS
i_callback_user_command = 'USER_COMMAND' " for User-Command
*&---------------------------------------------------------------------*
*& 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 REFRESH
WHEN 'REFRESH'.
* 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
Hope this helps you.
Regards,
Tarun
02-19-2010 10:49 AM
Hi,
do one thing.
you said that when the user clicks on 'Refresh' button on the tool bar the changed output values at that point of time has to be displayed right.
i thought that you are calling this fm 'reuse_alv_grid_display' in a module . you might have written the code after what to be happen when you click on that 'Refresh' button right.
so in that do like this.
...
when 'REFRESH'.
call the module in which you are calling the fm 'Reuse_alv_grid_display'.
here after displaying the list
CLEAR the workarea(if using) and REFRESH the final internal table(which contains the values to be displayed on the grid).
hope clear.
Thanks & regards,
Sasi Kanth.
02-19-2010 10:55 AM
Hi ,
U r requirement when the user enter the date in the selection screen that related date values will be displayed in that grid .
So that first of all u create a module pool program in that PBO create the grid.
Before the select statement refresh the internal table .( This will very use full to refresh the grid display for every time) .
using function modules : reuse_alv_grid_display.
using OOPS : First create a container using cl_gui_alv_grid
Second create grid for that container using cl_gui_custom_conatiner.
To display data using set_table_for_first_display(this is method of grid to display data ).
In the PAI event
case :
when user press Refresh button .
dont write any code there just u write back cancel and exit buttons .
after this event trigger it again goes to the PBO event .
In the PBO event Internal table will be refreshed .
and new values come to that grid.
Here only thing is refresh u r internaltables and work areas after your using completed.
Regards
Krishna
Edited by: sivakrishna boddapati on Feb 19, 2010 4:26 PM
03-24-2010 11:37 AM
1. Define your own "Refresh" button in the user interface.
2. In the form you defined for I_CALLBACK_USER_COMMAND, after you do whatever manipulation you want to do on the data, change the ucomm from to your "Refresh" to '&REFRESH'.