Posted: Wed Sep 05, 2007 7:06 pm Post subject: Customizing toolbar in ALVTree
Author: Vidya Gugnani
Often, one requires customizing the toolbar that appears in an ALV Tree and taking specific actions on choosing this button by triggering the specific handlers.
The following code snippet shows how this can be done in ABAP OO assuming you have a class which requires this handling and the following methods in the same will help you achieve this.
The following code snippet assumes that a filter button appears on given conditions only in the ALV tree and requires to be turned off at other times.
This is achieved in the following manner:
Assume the ALVTRee is created and now we wish to customize the toolbar for the same:
p_filter is the flag which decides if the filter button requires to be visible or not.
******************************************************************
*Create ALV tree prior to this in create_my_tree() method.
*Change the toolbar to suit our needs,pass the tree and filter as parameters.
.........
method create_toolbar.
create_my_tree().
if f_alvtree is not initial. __call_toolbar( tree = f_alvtree filter = p_filter ).
endif.
endmethod.
******************************************************************
*You could specify the toolbar by passing the instance variable f_toolbar which stores the toolbar instance and the filter options.
method __call_toolbar.
check tree is not initial.
tree->get_toolbar_object( importing er_toolbar = f_toolbar ).
f_filter_opt = filter.
__customize_toolbar( alvtreebar = f_toolbar refresh = f_filter_opt ).
endmethod.
******************************************************************
*Specify the tooltips that you wish for your toolbar items. Here *iconquick is a text icon defined in the dictionary.
*It also is optimal to group your icons in an icon package. Raise the event for handling the icon change ,define an event as below in your class.
******************************************************************
method __customize_toolbar.
set handler __handle_filter_selected for alvtreebar.
endif.
******************************************************************
* This method actually deals with the change on filter appearing/disappearing.
method __handle_filter_selected.
case fcode.
when 'FILOFF'.
check f_toolbar is not initial.
f_filter_opt = ''.
__handle_filter( ).
f_filter_opt = 'X'.
when 'FILON' .
check f_toolbar is not initial.
f_filter_opt = 'X'.
__handle_filter( ).
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.