2010 Feb 22 8:21 AM
Hi experts,
I put a refresh button onto the the ALV list. If it is pressed, I need to refresh the displaying of data.
I found an Object Oriented solution but I need a fm to solve this problem and so far I did not found which fm could I use.
Hi experts,
I put a refresh button onto the the ALV list. If it is pressed, I need to refresh the displaying of data.
I found an Object Oriented solution but I need a fm to solve this problem and so far I did not found which fm could I use.
2010 Feb 22 8:42 AM
Hi,
Just submit the same program again with the same selection screen parameters and return. Means program will be executed again and data will be refreshed.
Ganga
2010 Feb 22 8:55 AM
Use Submit - call the same program with the same selection parameters - u ll get a refreshed output.
2010 Feb 22 9:03 AM
HI,
On the User Command for the refresh Button click,
CHeck the sample code below:
*&---------------------------------------------------------------------*
*& 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 EXECUTE then process the selected records
WHEN 'EXECUTE'. "Here you can give func code of your refresh button
* refresh it_process when user processes selected records
REFRESH it_process.
* 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.
*----------------------------------------------------------------------*
* sort the internal table by flag descending so that the selected
* records are appended at the beginning of internal table
*----------------------------------------------------------------------*
SORT it_final BY flag DESCENDING.
*----------------------------------------------------------------------*
* move the selected records from final internal table into another
* internal table so that they can be processed
*----------------------------------------------------------------------*
LOOP AT it_final INTO wa_final WHERE flag = 'X'.
wa_process-aufnr = wa_final-aufnr.
wa_process-ktext = wa_final-ktext.
wa_process-qmnum = wa_final-qmnum.
APPEND wa_process TO it_process.
ENDLOOP.
* refresh the ALV Grid output from internal table
l_selfield-refresh = c_check.
* now all the selected records by the user at run-time are appended into
* into a new internal table which can now be used to processed as per the
* user requirements
DATA : line_count1 TYPE i.
DESCRIBE TABLE it_process
LINES line_count1.
IF line_count1 GE 1.
PERFORM user_action.
ELSE.
MESSAGE e002.
ENDIF.
WHEN 'SEL_ALL'.
* to select all the records displayed in ALV Grid
LOOP AT it_final INTO wa_final.
wa_final-flag = 'X'.
MODIFY it_final FROM wa_final.
ENDLOOP.
* refresh the ALV Grid output from internal table
l_selfield-refresh = c_check.
WHEN 'DESEL_ALL'.
* to deselect all the records displayed in ALV Grid
LOOP AT it_final INTO wa_final.
wa_final-flag = ' '.
MODIFY it_final FROM wa_final.
ENDLOOP.
* refresh the ALV Grid output from internal table
l_selfield-refresh = c_check.
ENDCASE.
ENDFORM. "USER_COMMAND
Hope it helps
Regards
Mansi
2010 Feb 22 10:30 AM
Mansi I cannot read this code, sorry. It just copied without any formatting. I doesn't help at all, since I cannot read it.
2010 Feb 22 10:37 AM
Why don't you submit the same program again with the same selection screen parameters and return?
Regards,
Ganga
2010 Feb 22 10:47 AM
I think selfield-refresh = 'X' is the most easiest way. I've already have the selection, all I need to do is just call the perform again.
Thanks anyway, submit program could be an option as well.
2010 Feb 22 9:04 AM
Hi,
Refer this code in the user command of the ALV in the below wiki by me:-
Hope this helps you.
Regards,
Tarun
2010 Feb 22 9:13 AM
Hi ,
Just Use the below FM with CL_GUI_ALV_GRID object .
CALL METHOD G_ALVGRID->REFRESH_TABLE_DISPLAY .
regards,
Amit
2010 Feb 22 9:20 AM
Hi,
When the USER_COMMAND is Triggered,
WHEN 'REFRESH'.
p_selfield-refresh = 'X'.
use the above scenario you will get it 100% correct.
Thanks & Regards,
Prasad.
2010 Feb 22 10:28 AM
selfield-refresh = 'X'.
I think maybe it could help. I have to perform the data selection before I set refresh to 'X'.
Like this one:
....
perform f_data_selection.
selfield-refresh = 'X'.
Edited by: mrwhite on Feb 22, 2010 11:33 AM
2015 Sep 28 8:20 AM
Hi Prasad,
Really you solution helped me..Thanks a lot.....
Its a 100% solution for refreshing an ALV o/P Grid...
2010 Feb 22 10:47 AM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |