‎2013 Jun 18 10:39 AM
Hi ,
i have created button in alv toolm bar and when i m triggering the evnet fro that buton calling refresh method but it is not working please see the code
*&---------------------------------------------------------------------*
*& Report SALV_DEMO_TABLE_EVENTS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
report salv_demo_table_events no standard page heading.
include <color>.
include <icon>.
include <symbol>.
types: begin of g_type_s_test,
amount type i,
repid type syrepid,
display type i,
dynamic type sap_bool,
end of g_type_s_test.
constants: gc_true type sap_bool value 'X'.
class lcl_handle_events definition deferred.
data: gs_test type g_type_s_test.
data: gt_outtab type standard table of sflight.
data: gr_table type ref to cl_salv_table.
data: gr_container type ref to cl_gui_custom_container.
data: gr_events type ref to lcl_handle_events.
data: g_okcode type sy-ucomm.
class lcl_handle_events definition.
public section.
methods:
on_user_command for event added_function of cl_salv_events
importing e_salv_function.
endclass.
class lcl_handle_events implementation.
method on_user_command.
perform show_function_info using e_salv_function text-i08.
endmethod.
endclass.
start-of-selection.
perform display_grid.
form display_grid.
call screen 101.
endform.
module d0100_pbo output.
perform d0100_pbo.
endmodule.
module d0100_pai input.
perform d0100_pai.
endmodule.
form d0100_pbo .
set pf-status 'D0100'.
if gr_container is not bound.
if cl_salv_table=>is_offline( ) eq if_salv_c_bool_sap=>false.
create object gr_container
exporting
container_name = 'CONTAINER'.
endif.
try.
cl_salv_table=>factory(
exporting
r_container = gr_container
container_name = 'CONTAINER'
importing
r_salv_table = gr_table
changing
t_table = gt_outtab ).
catch cx_salv_msg. "#EC NO_HANDLER
endtry.
select * from sflight into table gt_outtab.
data: lr_functions type ref to cl_salv_functions_list,
l_text type string,
l_icon type string.
lr_functions = gr_table->get_functions( ).
lr_functions->set_all( gc_true ).
try.
l_text = text-b01.
l_icon = icon_complete.
lr_functions->add_function(
name = 'Refresh'
icon = l_icon
text = 'Refresh'
tooltip = l_text
position = if_salv_c_function_position=>right_of_salv_functions ).
catch cx_salv_wrong_call cx_salv_existing.
endtry.
data: lr_columns type ref to cl_salv_columns_table,
lr_column type ref to cl_salv_column_table.
lr_columns = gr_table->get_columns( ).
lr_columns->set_optimize( gc_true ).
* perform set_columns_technical using lr_columns.
try.
lr_column ?= lr_columns->get_column( 'CARRID' ).
lr_column->set_cell_type( if_salv_c_cell_type=>hotspot ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
data: lr_events type ref to cl_salv_events_table.
lr_events = gr_table->get_event( ).
create object gr_events.
set handler gr_events->on_user_command for lr_events.
data: lr_display_settings type ref to cl_salv_display_settings,
l_title type lvc_title.
l_title = text-t01.
lr_display_settings = gr_table->get_display_settings( ).
lr_display_settings->set_list_header( l_title ).
gr_table->display( ).
endif.
endform. " d0100_pbo
form d0100_pai .
case sy-ucomm .
when 'BACK' or 'EXIT' or 'CANC' or 'HI'.
leave program .
.
endcase.
endform. " d0100_pai
*&---------------------------------------------------------------------*
*& Form show_function_info
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form show_function_info using i_function type salv_de_function
i_text type string.
data: l_string type string.
gr_table->refresh( ).
concatenate i_text i_function into l_string separated by space.
message i000(0k) with l_string.
endform. " show_function_info
‎2013 Jun 18 12:25 PM
‎2013 Jun 18 12:35 PM
Hi Ravi,
Pass the method name 'refresh' in the same case(lower case) in the below mentioned place:
try.
l_text = text-b01.
l_icon = icon_complete.
lr_functions->add_function(
name = 'Refresh'
icon = l_icon
text = 'Refresh'
tooltip = l_text
position = if_salv_c_function_position=>right_of_salv_functions ).
catch cx_salv_wrong_call cx_salv_existing.
endtry.
I hope it helps...rest is fine...
‎2013 Jun 18 12:57 PM
‎2013 Jun 18 12:37 PM
form d0100_pai .
case sy-ucomm .
when 'BACK' or 'EXIT' or 'CANC' or 'HI'.
leave program .
endcase.
endform. " d0100_pai
you forget to add
CASE OTHERS.
CALL METHOD cl_gui_cfw=>dispatch.
regards
Fred
‎2013 Jun 18 1:00 PM
‎2013 Jun 25 7:51 AM
Since there seems to be a reluctance to give detail information to solve this problem, I will mark it as assumed answered and lock it.