2007 Jul 10 5:56 AM
HI all,
i have a requirement where the user can double click on a value on the alv and that call the transaction to edit and save changes .. however when the user return the ALV should display the changed values..
The problem is that by the time I reselect the data the database has not been updated .. so even after a reselection the get the old values....
I have tried the wait statement which works ... however is there any other alternative .. is there any way we can find out if the LUW for the Transaction has been closed or the Database has been updated so that we can perform the reselection and get the updated.values.
have tried PERFORM ON COMMIT doesn't work.!!!!
please suggest.
Thanks in advance
Srinivas
2007 Jul 10 5:59 AM
Hi,
Commit work.
Wait upto 2 seconds.
This is the option.
If you want to indicate to the user, that system is processing the data, then call the FM SAPGUI_PROGRESS_INDICATOR
Best regards,
Prashant
2007 Jul 10 6:07 AM
Thanks Prashant for the Reply,,
Just had a doubt .. does this ensure that the data base selection performed will be getting the recent data ...
In a scenario where the Luw is taking more time to update the DB wait 2 sec might not be help.
Thanks
Srinivas
2007 Jul 10 6:23 AM
Why not add Refresh button and then user can refresh the screen if the data is not updated yet.
2007 Jul 10 6:25 AM
Hi,
In ALV, to refresh the table you have to call the method "refresh_table_display".
It has the syntax very similar to creating the table.
It has two parameters. In the first one, you can mention if you want to refresh only the data (the icons are not refreshed)
or
if you want to refresh only the icons around the grid (the data is not refreshed - this option is mostly not used in day to day applications).
the synatx is :-
call method grid (name of grid )->refresh_table_display
exporting
IS_STABLE = <STRUCT OF TYPE LVC_S_STBL> (THIS IS FOR DATA REFRESHING)
I_SOFT_REFRESH = <VARIABLE OF CHAR 01> (THIS IS FOR ICON REFRESHING).
Regards,
Bhaskar
2007 Jul 10 7:00 AM
hi all,
Well the table is refreshing well its only that when i make a reselection i m not getting the updated values as the LUW for the transaction code might not have updated the DATabase.
if i debug the same it works .... coz by the time i make the reselection the DB luw is done with the update.
I m looking for something that can delay my reselecting the Database until the Databse has been updated ....
have tried wait statement and thgis works fine but then this may hamper the Performance .....i m looking for any alternative.
so that when i fetch i get the recent values
Thanks
Srinivas
2007 Jul 10 6:26 AM
2007 Jul 10 6:35 AM
Example of the Auto refresh ....
<b>Auto Refresh ALV List</b>
REPORT z_alv_auto_refresh.
*>*********************************************************************
* This report displays User's info (SM04) using the FM : *
* REUSE_ALV_LIST_DISPLAY *
* The list is auto-refreshed (refresh time : 5 seconds) *
*---------------------------------------------------------------------*
TYPE-POOLS: slis. " ALV Global Types
DATA :
gt_user LIKE uinfo OCCURS 0 WITH HEADER LINE. " User info in SM04
*---------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM f_read_data.
PERFORM f_display_data.
*---------------------------------------------------------------------*
* Form F_LIRE_DATA
*---------------------------------------------------------------------*
FORM f_read_data.
REFRESH gt_user.
* Get User's info
CALL FUNCTION 'THUSRINFO'
TABLES
usr_tabl = gt_user.
* Wait in a task
PERFORM f_call_rfc_wait.
ENDFORM. " F_READ_DATA
*---------------------------------------------------------------------*
* Form F_DISPLAY_DATA
*---------------------------------------------------------------------*
FORM f_display_data.
DEFINE m_sort.
add 1 to ls_sort-spos.
ls_sort-fieldname = &1.
append ls_sort to lt_sort.
END-OF-DEFINITION.
DEFINE m_event_exit.
clear ls_event_exit.
ls_event_exit-ucomm = &1.
ls_event_exit-after = 'X'.
append ls_event_exit to lt_event_exit.
END-OF-DEFINITION.
DATA :
ls_layout TYPE slis_layout_alv,
lt_sort TYPE slis_t_sortinfo_alv,
ls_sort TYPE slis_sortinfo_alv,
lt_event_exit TYPE slis_t_event_exit,
ls_event_exit TYPE slis_event_exit.
* Build Sort Table
m_sort 'ZEIT'.
* Build Event Exit Table
m_event_exit '&NTE'. " Refresh
ls_layout-zebra = 'X'.
ls_layout-colwidth_optimize = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_user_command = 'USER_COMMAND'
is_layout = ls_layout
i_structure_name = 'UINFO'
it_sort = lt_sort
it_event_exit = lt_event_exit
TABLES
t_outtab = gt_user.
ENDFORM. " F_DISPLAY_DATA
*---------------------------------------------------------------------*
* FORM USER_COMMAND *
*---------------------------------------------------------------------*
FORM user_command USING i_ucomm TYPE syucomm
is_selfield TYPE slis_selfield. "#EC CALLED
CASE i_ucomm.
WHEN '&NTE'.
PERFORM f_read_data.
is_selfield-refresh = 'X'.
SET USER-COMMAND '&OPT'. " Optimize columns width
ENDCASE.
ENDFORM. " USER_COMMAND
*---------------------------------------------------------------------*
* Form F_CALL_RFC_WAIT
*---------------------------------------------------------------------*
FORM f_call_rfc_wait.
DATA lv_mssg(80). "#EC NEEDED
* Wait in a task
CALL FUNCTION 'RFC_PING_AND_WAIT' STARTING NEW TASK '001'
PERFORMING f_task_end ON END OF TASK
EXPORTING
seconds = 5 " Refresh time
busy_waiting = space
EXCEPTIONS
RESOURCE_FAILURE = 1
communication_failure = 2 MESSAGE lv_mssg
system_failure = 3 MESSAGE lv_mssg
OTHERS = 4.
ENDFORM. " F_CALL_RFC_WAIT
*---------------------------------------------------------------------*
* Form F_TASK_END
*---------------------------------------------------------------------*
FORM f_task_end USING u_taskname.
DATA lv_mssg(80). "#EC NEEDED
* Receiving task results
RECEIVE RESULTS FROM FUNCTION 'RFC_PING_AND_WAIT'
EXCEPTIONS
RESOURCE_FAILURE = 1
communication_failure = 2 MESSAGE lv_mssg
system_failure = 3 MESSAGE lv_mssg
OTHERS = 4.
CHECK sy-subrc EQ 0.
SET USER-COMMAND '&NTE'. " Refresh
ENDFORM. " F_TASK_END
*************** END OF PROGRAM Z_ALV_AUTO_REFRESH *********************
reward points if it is usefull ....
Girish
2007 Jul 10 1:31 PM
Hi,
The following method call is used to refresh the data displayed within an ALV object grid:
CALL method gd_tree->REFRESH_TABLE_DISPLAY.
CALL METHOD gd_tree->set_table_for_first_display
EXPORTING
is_layout = gd_layout
CHANGING
it_fieldcatalog = gd_fieldcat
it_sort = it_sortcat
it_outtab = it_report.
CALL method gd_tree->REFRESH_TABLE_DISPLAY.
CALL METHOD cl_gui_cfw=>flush.
Hope this helps.
Reward if helpful.
Regards,
Sipra