2013 Jul 09 9:05 AM
Hi all,
I've created a SALV and put it into a container. The container is located at the left side of my screen like a dock.
Now I've added a new Function Key into the GUI Status. This new Function is the Refresh.
What I want :
Refresh my "Dock" (SALV) when the user click on the refresh button.
In order to to this I've called the refresh method of the SALV:
gr_gralv->refresh( refresh mode = if_salv_refresh=>full).
Unfortunately that not working although in debugging mode my internal table corresponding to the SALV contains the right data.
If anyone can help me
Regards,
Sam
2013 Jul 09 7:59 PM
Hi Sam,
Your problem seems like with each click of the 'Refresh' button you are creating a new instance for the container. Me too had the same problem which was resolved when i put a condition check to verify if the container object is initial before creating the specific object in the PBO.
I would suggest to use 'IF container IS INITIAL' condition check before creating the container object and also 'IF salv_table IS INITIAL' condition check before creating the cl_salv_table object to make sure that you are creating the object only if it is not created so far. This condition checks have made the refresh function working for me just fine.
Thanks & Regards,
Sarath
2013 Jul 09 9:16 AM
check SALV * demo programs in SE38 like:
SALV_DEMO_TABLE_REFRESH
SALV_TEST_REFRESH
Regards
2013 Jul 09 10:34 AM
Hi,
try with this:
gr_gralv->refresh( refresh_mode = if_salv_c_refresh=>full ).
Best regards.
2013 Jul 09 12:07 PM
2013 Jul 09 2:34 PM
Hi,
maybe something like:
gr_gralv->close_screen( ).
IF NOT gr_gralv IS INITIAL.
gr_gralv->refresh( refresh_mode = if_salv_c_refresh=>full ).
ENDIF.
PERFORM select_data."load the internal table again
Best regards.
2013 Jul 09 4:16 PM
2013 Jul 09 10:39 AM
2013 Jul 09 12:16 PM
Hi Vaman,
This statement also not working.
Something weird is happening. After the first refresh the data is correctly refreshed but after it doesn't work.
Thank
2013 Jul 09 12:21 PM
Hi,
May be you will have to check the demo program SALV_TEST_TABLE_EVENTS for better understanding of how you can use the events to refresh.
Cheers,
Arindam
2013 Jul 09 6:44 PM
Hi,
I tried the refresh method in PAI..and it seems to be working fine..after modifying the internal table..
obj_alv->refresh( EXPORTING refresh_mode = 2 )..
Check in PBO..if you are populating the data again...
Thanks
Naren
2013 Jul 09 6:56 PM
Hi,
Thank you for your reply.
I'm doing exactly like you :
I also check my PBO, my data isn't modified...
2013 Jul 09 7:04 PM
hmm...may be it depends on the netweaver version...
we are in Release 7.31 and level 5
I created the below code..and it works fine for me..
REPORT ztest.
DATA t_t001 TYPE STANDARD TABLE OF t001.
DATA: gr_container TYPE REF TO cl_gui_custom_container.
DATA: ok_code TYPE syucomm.
PARAMETERS: p_test TYPE matnr DEFAULT 'TEST'.
DATA: obj_alv TYPE REF TO cl_salv_table.
START-OF-SELECTION.
SELECT * FROM t001 INTO TABLE t_t001.
CALL SCREEN '0100'.
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV
*&---------------------------------------------------------------------*
* text
*&---------------------------------------------------------------------*
FORM display_alv .
IF gr_container IS NOT BOUND.
CREATE OBJECT gr_container
EXPORTING
container_name = 'CONTAINER'.
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
list_display = if_salv_c_bool_sap=>false
r_container = gr_container
container_name = 'CONTAINER'
IMPORTING
r_salv_table = obj_alv
CHANGING
t_table = t_t001.
obj_alv->display( ).
CATCH cx_salv_msg.
MESSAGE ID 'BC' TYPE 'S' NUMBER '202' WITH 'cx_salv_msg' sy-msgv1
sy-msgv2 'cl_salv_table=>factory'.
ENDTRY.
ENDIF.
ENDFORM. " DISPLAY_ALV
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS '0100'.
PERFORM display_alv.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'BACK' OR 'EXIT' OR 'CANC'.
SET SCREEN 0.
LEAVE SCREEN.
WHEN 'REFRESH'.
DO 25 TIMES.
DELETE t_t001 INDEX 1.
ENDDO.
obj_alv->refresh( EXPORTING refresh_mode = 2 ).
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
Thanks
Naren
2013 Jul 10 1:17 PM
2013 Jul 09 7:59 PM
Hi Sam,
Your problem seems like with each click of the 'Refresh' button you are creating a new instance for the container. Me too had the same problem which was resolved when i put a condition check to verify if the container object is initial before creating the specific object in the PBO.
I would suggest to use 'IF container IS INITIAL' condition check before creating the container object and also 'IF salv_table IS INITIAL' condition check before creating the cl_salv_table object to make sure that you are creating the object only if it is not created so far. This condition checks have made the refresh function working for me just fine.
Thanks & Regards,
Sarath
2013 Jul 10 6:36 AM
Hi Sarath,
Here my code.
It seems to me that I'm already doing like you said.
FORM dock_display .
DATA: lr_grcol TYPE REF TO cl_salv_column,
lr_grcls TYPE REF TO cl_salv_columns,
lr_grevt TYPE REF TO cl_salv_events_table,
lr_grlab TYPE REF TO cl_salv_form_label, "#EC NEEDED
lr_grlay TYPE REF TO cl_salv_form_layout_grid,
lr_grsel TYPE REF TO cl_salv_selections,
lx_alvms TYPE REF TO cx_salv_msg,
lx_alvnf TYPE REF TO cx_salv_not_found,
lr_event TYPE REF TO cl_cckpt.
* Check if the docking container already exist
IF gr_cclst IS NOT BOUND.
CREATE OBJECT gr_cclst
EXPORTING
repid = sy-repid
dynnr = '0100'
extension = 600
side = gr_cclst->dock_at_left.
ENDIF.
TRY.
cl_salv_table=>factory( EXPORTING r_container = gr_cclst
IMPORTING r_salv_table = gr_gralv
CHANGING t_table = gt_dockt[] ).
CREATE OBJECT lr_grlay.
* Header text
lr_grlab = lr_grlay->create_label( text = text-009
row = 1
column = 1
colspan = 1 ).
gr_gralv->set_top_of_list( lr_grlay ).
lr_grcls = gr_gralv->get_columns( ).
lr_grcol = lr_grcls->get_column( 'DISPL' ).
lr_grcol->set_alignment( if_salv_c_alignment=>centered ).
lr_grcol->set_short_text( 'S/S/D' ).
lr_grcol->set_medium_text( 'Store Shift Date ' ).
lr_grcol->set_long_text( 'Store Shift Date Number Counter' ).
lr_grcol->set_tooltip( text-009 ).
lr_grcol = lr_grcls->get_column( 'XFUEL' ).
lr_grcol->set_alignment( if_salv_c_alignment=>centered ).
lr_grcol->set_short_text( 'FUL' ).
lr_grcol->set_medium_text( 'FUL' ).
lr_grcol->set_long_text( 'FUL' ).
lr_grcol->set_tooltip( text-004 ).
lr_grcol = lr_grcls->get_column( 'XMDRY' ).
lr_grcol->set_alignment( if_salv_c_alignment=>centered ).
lr_grcol->set_short_text( 'RTL' ).
lr_grcol->set_medium_text( 'RTL' ).
lr_grcol->set_long_text( 'RTL' ).
lr_grcol->set_tooltip( text-005 ).
lr_grcol = lr_grcls->get_column( 'XTOTL' ).
lr_grcol->set_alignment( if_salv_c_alignment=>centered ).
lr_grcol->set_short_text( 'TTL' ).
lr_grcol->set_medium_text( 'TTL' ).
lr_grcol->set_long_text( 'TTL' ).
lr_grcol->set_tooltip( text-006 ).
lr_grcol = lr_grcls->get_column( 'CLOSE' ).
lr_grcol->set_alignment( if_salv_c_alignment=>centered ).
lr_grcol->set_short_text( 'CLS' ).
lr_grcol->set_medium_text( 'CLS' ).
lr_grcol->set_long_text( 'CLS' ).
lr_grcol->set_tooltip( text-007 ).
lr_grcol = lr_grcls->get_column( 'CORRT' ).
lr_grcol->set_alignment( if_salv_c_alignment=>centered ).
lr_grcol->set_short_text( 'COR' ).
lr_grcol->set_medium_text( 'COR' ).
lr_grcol->set_long_text( 'COR' ).
lr_grcol->set_tooltip( text-008 ).
* Handle Double Click
CREATE OBJECT lr_event.
lr_grevt = gr_gralv->get_event( ).
SET HANDLER: lr_event->dclic FOR lr_grevt.
* Selections management
lr_grsel = gr_gralv->get_selections( ).
lr_grsel->set_selection_mode( if_salv_c_selection_mode=>single ).
gr_gralv->display( ).
CATCH cx_salv_msg INTO lx_alvms.
MESSAGE lx_alvms TYPE 'I' DISPLAY LIKE 'E'.
CATCH cx_salv_not_found INTO lx_alvnf.
MESSAGE lx_alvnf TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
gr_cclst->set_visible( 'X' ).
* Case 1st row is selected
IF gv_selec EQ 'X'.
PERFORM dock_select USING 1.
CLEAR gv_selec.
ENDIF.
ENDFORM.
2013 Jul 10 1:52 PM
Hi,
Finally I found the solution.
Like said Sarath i just add the check below before creating the SALV:
IF gr_gralv IS BOUND.
RETURN.
ENDIF.
I have no technical explanation for this.
Before this change I created each time the refresh is called, a new instance of the SALV. So why it didn't work ?
However thank you all for your help.
Regards,
Sam
2021 Oct 01 4:38 PM
For me, this seemed to make the difference. My table was changed in another transaction, so I needed to re-read the data into my internal table but it seems we needed the cl_salv_table->set_data method...
Big thanks to netweaver.developer for suggesting SALV_DEMO_TABLE_REFRESH
try.
call method gr_table->set_data
changing t_table = new_outtab.
catch CX_SALV_NO_NEW_DATA_ALLOWED.
endtry.
2023 Aug 21 2:21 PM
Not calling the factory method of cl_salv_table more than once seems to fix this issue.
So, simply make sure the factory method is only being invoked once and call the refresh method on the salv before calling the screen which should show the SALV table to ensure the updated data will be shown.
It's important to note that the output table as well as the reference to cl_salv_table has to be declared globally.
data gx_custom_container type ref to cl_gui_custom_container.
data gx_salv type ref to cl_salv_table.
data gt_test_data type table of spfli.
IF NOT ( lr_salv is bound ).
TRY.
gx_custom_container = new #( 'NAME_OF_CUSTOM_CONTAINER_DECLARED_IN_SCREEN_PAINTER' ).
cl_salv_table=>factory( EXPORTING r_container = gx_custom_container
IMPORTING r_salv_table = gx_salv
CHANGING t_table = gt_test_data ).
gx_salv->display( ).
CATCH cx_salv_msg.
ENDTRY.
ENDIF.
gx_salv ->refresh( ).
call screen 100. "Example screen number
2023 Sep 04 2:35 PM
FYI the same answer was already posted in 2013 and has solved the OP problem.