2009 Dec 04 12:19 PM
Hi,
I'm using the new way to do ALV grids - I have a customised button called 'DIRECT' on the toolbar but dont know how to disable it have tried to use the CL_SALV_FUNCTIONS->remove_function method but it keeps on coming back with an exception stating that I am using a wrong call
data: gt_table type ref to cl_salv_table.
data: l_t100 type t100,
l_save(10).
data: gr_layout type ref to cl_salv_layout.
data: key type salv_s_layout_key.
try.
cl_salv_table=>factory(
importing
r_salv_table = gt_table
changing
t_table = it_boc_document ).
catch cx_salv_msg.
endtry.
gr_layout = gt_table->get_layout( ).
key-report = sy-repid.
gr_layout->set_key( key ).
gr_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
"Set the pf-status
try.
gt_table->set_screen_status(
pfstatus = 'ALV_STATUS'
report = sy-repid
set_functions = gt_table->c_functions_all ).
catch cx_salv_msg.
endtry.
gt_table->display( ).
Any help would be appreciated.
Many thanks in advance
Raj
2009 Dec 04 3:56 PM
You need to set the Visibility of the required function to hide it.
Like:
gr_table->set_screen_status(
pfstatus = 'SALV_STANDARD'
report = gs_test-repid
set_functions = gr_table->c_functions_all ).
DATA: lo_functions TYPE REF TO cl_salv_functions,
lt_func_list TYPE salv_t_ui_func,
la_func_list LIKE LINE OF lt_func_list.
* Get all functions
lo_functions = gr_table->get_functions( ).
lt_func_list = lo_functions->get_functions( ).
* Now hide the MYFUNCTION
LOOP AT lt_func_list INTO la_func_list.
IF la_func_list-r_function->get_name( ) = 'MYFUNCTION'.
la_func_list-r_function->set_visible( ' ' ).
ENDIF.
ENDLOOP.
Regards,
Naimesh Patel
2009 Dec 04 12:33 PM
Hi Raj,
ALV Grid control allows you to add your own functions triggered by a button press on the ALV toolbar. For this, we mainly utilize two of ALV Grid events. We use the event TOOLBAR to add the button and the event USER_COMMAND to implement the new function.
In the method handling the TOOLBAR event, we define a new button by filling a structure and appending it to the table attribute MT_TOOLBAR of the object to whose reference we can reach via the parameter E_OBJECT of the event.
The field of the structure for your requirement will be DISABLED.
Refer below code :-
CLEAR ls_toolbar.
MOVE 'EXCH' TO ls_toolbar-function.
MOVE 2 TO ls_toolbar-butn_type.
MOVE icon_calculation TO ls_toolbar-icon.
MOVE 'Payment in Other Currencies'(202) TO ls_toolbar-quickinfo.
MOVE ' ' TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO i_object->mt_toolbar.
Regards
Abhii
2009 Dec 04 3:56 PM
You need to set the Visibility of the required function to hide it.
Like:
gr_table->set_screen_status(
pfstatus = 'SALV_STANDARD'
report = gs_test-repid
set_functions = gr_table->c_functions_all ).
DATA: lo_functions TYPE REF TO cl_salv_functions,
lt_func_list TYPE salv_t_ui_func,
la_func_list LIKE LINE OF lt_func_list.
* Get all functions
lo_functions = gr_table->get_functions( ).
lt_func_list = lo_functions->get_functions( ).
* Now hide the MYFUNCTION
LOOP AT lt_func_list INTO la_func_list.
IF la_func_list-r_function->get_name( ) = 'MYFUNCTION'.
la_func_list-r_function->set_visible( ' ' ).
ENDIF.
ENDLOOP.
Regards,
Naimesh Patel
2009 Dec 04 4:19 PM
2014 Jan 31 8:26 AM
Hi Experts,
I have a requirement to disable (not hide) the button in application toolbar. I have also tried the method SET_ENABLE, but it hides the button.
Regards,
Ashok
2019 Oct 23 8:42 AM
Hi,
For a few of you, the code suggested by Naimesh might not work as you have created a custom button by accessing status through SE38 instead of SE41. In this case, ALV buffer gets struck. So please run program BALVBUFDEL to clear the buffer. I hope it will resolve your issue.
Thanks,
Nitin Shekhawat
2021 Oct 08 11:47 AM