The SALV is really nice, unfortunately the toolbar can only be enhanced when the SALV with assigend to a container... so you have to provide a Dynpro
Example:
Selection Screen:
parameters p_layout type slis_vari.
at selection-screen on value-request for p_layout.
p_layout = lcl_o=>layout_f4( ).
The method pai is called from pai module of the dynpro containing the custom container CC
method pai.
check mo_cc is not bound.
" read data from db
read( ... ).
" prepare front end
mo_cc = new cl_gui_custom_container( 'CC' ).
try.
" setup SALV
cl_salv_table=>factory(
exporting r_container = mo_cc
importing r_salv_table = mo_salv
changing t_table = ...
).
" prepare SALV
mo_salv->get_columns( )->get_column( 'ORDERID' )->set_visible( abap_false ).
cast cl_salv_column_table(
mo_salv->get_columns( )->get_column( 'ORDERNR' )
)->set_cell_type( if_salv_c_cell_type=>hotspot ).
mo_salv->get_sorts( )->add_sort( 'STARTTI' ).
mo_salv->get_sorts( )->add_sort( 'ENDTI' ).
mo_salv->get_selections( )->set_selection_mode(
if_salv_c_selection_mode=>multiple ).
" prepare toolbar
mo_salv->get_functions( )->set_all( ). " activate toolbar
mo_salv->get_functions( )->add_function(
name = 'REFRESH'
icon = '@42@'
tooltip = conv string( 'Aktualisieren'(010) )
position = if_salv_c_function_position=>left_of_salv_functions
).
mo_salv->get_layout( )->set_key( value salv_s_layout_key(
report = sy-repid ) ).
mo_salv->get_layout( )->set_save_restriction(
cl_salv_layout=>restrict_none ).
mo_salv->get_layout( )->set_initial_layout( mv_layout ).
" setup event handlers
set handler on_user_command for mo_salv->get_event( ).
set handler on_hot_spot for mo_salv->get_event( ).
" Display SALV
mo_salv->display( ).
catch
cx_salv_msg
cx_salv_not_found
cx_salv_data_error
cx_salv_existing
cx_salv_wrong_call into data(lo_x).
message lo_x type 'E'.
endtry.
endmethod.
method on_user_command.
case e_salv_function.
when 'CREATE'. dialog_create( ).
when 'DELETE'. dialog_delete( ).
when 'REFRESH'. refresh( ).
endcase.
endmethod.
method on_hot_spot.
data lt_bdc type standard table of bdcdata with empty key.
lt_bdc = value #(
( program = '/SAPAPO/SAPRRP_ENTRY' dynpro = '2000' dynbegin = 'X' )
( fnam = 'BDC_CURSOR' fval = '/SAPAPO/RRPIO-SL_PRORDER' )
( fnam = 'BDC_OKCODE' fval = '=ORDTYPE_CHANGE' )
( fnam = '/SAPAPO/RRPIO-SL_CUORDER' fval = '' )
( fnam = '/SAPAPO/RRPIO-SL_PRORDER' fval = 'X' )
( program = '/SAPAPO/SAPRRP_ENTRY' dynpro = '2000' dynbegin = 'X' )
( fnam = 'BDC_CURSOR' fval = '/SAPAPO/RRPIO-DELNRPR' )
( fnam = 'BDC_OKCODE' fval = '=SHOW' )
( fnam = '/SAPAPO/RRPIO-DELNRPR' fval = mt_opr_d[ row ]-ordernr )
).
data(ls_opt) = value ctu_params( dismode = 'E' defsize = 'X' ).
call transaction '/SAPAPO/RRP2' using lt_bdc options from ls_opt.
endmethod.
CLASS-METHODS on_user_command FOR EVENT added_function OF cl_salv_events IMPORTING e_salv_function.