‎2009 Jan 22 9:07 AM
Hi Abapers,
I have created a ALV, i need to include SAP Provided refresh button in ALV output so that when user hits this button, Report should be generated using same selection just with most recent data.. I'm planning to use submit statement with selection screen skip option.. Is this the only way? or any other alternative available?
Please help me..
‎2009 Jan 22 9:19 AM
Hi,
You can do it other ways also.
Refer:
http://www.sap-img.com/abap/how-to-refresh-alv-list-grid-once-it-is-displayed.htm
http://www.sap-basis-abap.com/abap/auto-refresh-alv-list.htm
Edited by: AJAY TIWARI on Jan 22, 2009 10:21 AM
‎2009 Jan 22 9:12 AM
Hi
There is a refresh icon ('update' icon-two arrows in blue following each other) on the application tool bar of any ALV report. Click that icon once and the report will get refresh automatically.
‎2009 Jan 22 9:13 AM
Hi
No! It's a bad solution: u should create a routine in order to get and load the data to be printed and call this routine before calling ALV and after refreshing ALV.
Something like this:
TYPE-POOLS SLIS.
TABLES: BKPF.
PARAMETERS: P_BUKRS TYPE BKPF-BUKRS.
SELECT-OPTIONS: SO_BELNR FOR BKPF-BELNR,
SO_GJAHR FOR BKPF-GJAHR,
SO_BUDAT FOR BKPF-BUDAT.
DATA: LT_REPORT TYPE SY-REPID.
DATA: T_OUTPUT TYPE TABLE OF BKPF.
START-OF-SELECTION.
PERFORM LOAD_DATA.
END-OF-SELECTION.
LT_REPORT = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = LT_REPORT
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_STRUCTURE_NAME = 'BKPF'
TABLES
T_OUTTAB = T_OUTPUT.
*&---------------------------------------------------------------------*
*& Form LOAD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM LOAD_DATA.
SELECT * FROM BKPF INTO TABLE T_OUTPUT
WHERE BUKRS = P_BUKRS
AND BELNR IN SO_BELNR
AND GJAHR IN SO_GJAHR
AND BUDAT IN SO_BUDAT.
ENDFORM. " LOAD_DATA
*---------------------------------------------------------------------*
* FORM set_pf_status *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> RT_EXTAB *
*---------------------------------------------------------------------*
FORM SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'MY_ALV' EXCLUDING RT_EXTAB.
ENDFORM.
*---------------------------------------------------------------------*
* FORM user_command *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> R_UCOMM *
* --> RS_SELFIELD *
*---------------------------------------------------------------------*
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN 'REFRESH'.
PERFORM LOAD_DATA.
RS_SELFIELD-REFRESH = 'X'.
WHEN OTHERS.
ENDCASE.
ENDFORM.Max
‎2009 Jan 22 9:17 AM
Hi
see this code it will refresh the program output for every 5 sec automatically.
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 ********************
‎2009 Jan 22 9:18 AM
Hi Premraj,
You can have forms for that, for ex.
"In normal flow
perform fill_values. "fill the int table from db table acco to selection
perform display_alv. "display int tab with alv
"when the user command is refresh then,
perform fill_values. "fill the int table with recent values from db table acco to selection
perform display_alv. "display int tab with alvRegards,
Manoj Kumar P
‎2009 Jan 22 9:19 AM
Hi,
You can do it other ways also.
Refer:
http://www.sap-img.com/abap/how-to-refresh-alv-list-grid-once-it-is-displayed.htm
http://www.sap-basis-abap.com/abap/auto-refresh-alv-list.htm
Edited by: AJAY TIWARI on Jan 22, 2009 10:21 AM
‎2009 Jan 22 10:31 AM
Hi
I guess u need to fetch the recent data for the same selection criteria. Right..?
If so, have that refresh button and when user presses refresh button that time, call all the performs which fetches data,processes and shows the output.
That would be fine. No need to submit again and skip selection....etc.
Venkat.