04-22-2009 9:25 AM
Hello,
I have disabled a button of the alv when I call the dynpro at pbo. So how can I set the status of the button to active by editing user command.
04-22-2009 2:50 PM
04-22-2009 2:51 PM
yes it is in the alv toolbar, i have added into it, the problem is that I want to display the button when I click on another button.
04-22-2009 2:54 PM
use set pf-status < >.
on user command set 1 2 on other user command set-pf status 1 2
04-22-2009 2:55 PM
i dont mean the pf-status, I mean the tollbar which I create with the event toolbar
04-22-2009 2:58 PM
I hope you are using the class CL_GUI_ALV_GRID for fdisplay. In that class u have a method SET_TOOLBAR_BUTTONS in which u can disable and enable your toolbar buttons..
04-22-2009 8:36 PM
do have me an example for this mentioned method? Yes I use this class for creating the alv
04-22-2009 9:42 PM
Hello
You may have a look at the (unfortunately misformatted) coding of sample report ZUS_SDN_ALVGRID_EDITABLE_8A in thread
The crucial point are:
(0) Define event handler for event TOOLBAR.
(1) Call method go_grid->set_toolbar_interactive( ) at PBO of your screen.
(2) Within method HANDLE_TOOLBAR inactivate your ALV toolbar button.
When the user pushes a function which should enable the toolbar button then set a flag and store this (e.g. in a static attribute of your event handler class: LCL_EVENTHANDLER=>MD_SWITCH).
Whitin method HANDLE_TOOLBAR you evalute the switch:
IF ( md_switch = abap_true ).
" activate toolbar function again -> or do not inactivate it
ELSE.
" inactivate toolbar function
ENDIF.
Regards
Uwe
04-22-2009 10:14 PM
but when I activate the button shall I have to create the toolbar complete new for the alv?
04-22-2009 10:20 PM
Hello
The ALV toolbar is there by default. In the event handler method HANDLE_TOOLBAR you manipulate the toolbar functions as you like:
data: ls_button TYPE stb_button.
LOOP AT e_object->mt_toolbar INTO ls_button.
CASE ls_button-function.
WHEN '...'.
ls_button-disabled = abap_true. " inactivate
WHEN '...'.
" do nothing -> i.e. function active
WHEN OTHERS.
DELETE e_object->mt_toolbar INDEX syst-tabix. " remove from toolbar
ENDCASE.
MODIFY e_object->mt_toolbar FROM ls_button INDEX syst-tabix.
ENDLOOP.
Regards
Uwe
04-24-2009 4:36 PM
Thank you Uwe for your answer, it works very well, but one question.
In my coding I create several buttons in the toolbar of the ALV.
CLASS lcl_event_handler IMPLEMENTATION.
METHOD toolbar.
PERFORM toolbar USING e_object.
ENDMETHOD. "toolbar
ENDCLASS. "lcl_event_handler IMPLEMENTATION
FORM toolbar USING p_e_object TYPE REF TO cl_alv_event_toolbar_set.
CLEAR gs_toolbar.
gs_toolbar-function = 'OPEN'.
gs_toolbar-icon = icon_status_open.
gs_toolbar-text = text-003.
gs_toolbar-butn_type = '0'.
gs_toolbar-quickinfo = text-003.
gs_toolbar-checked = space.
gs_toolbar-disabled = 'X'.
APPEND gs_toolbar TO p_e_object->mt_toolbar.
CLEAR gs_toolbar.
gs_toolbar-function = 'POST'.
gs_toolbar-icon = icon_execute_object.
gs_toolbar-text = text-002.
gs_toolbar-butn_type = '0'.
gs_toolbar-disabled = space.
gs_toolbar-quickinfo = text-002.
gs_toolbar-checked = space.
APPEND gs_toolbar TO p_e_object->mt_toolbar.
LOOP AT p_e_object->mt_toolbar INTO gs_toolbar.
IF gf_check = 2.
CASE gs_toolbar-function.
WHEN 'OPEN'.
gs_toolbar-disabled = 'X'.
MODIFY p_e_object->mt_toolbar FROM gs_toolbar INDEX syst-tabix.
WHEN 'POST'.
gs_toolbar-disabled = space.
MODIFY p_e_object->mt_toolbar FROM gs_toolbar INDEX syst-tabix.
ENDCASE.
Endif.
Endform.
The problem is, when I click on a button, he always generate the whole buttons which I add to the toolbar.
How can I solve this that he only has to build the toolbar once and then he only change the disabled parameter?
04-26-2009 1:25 PM
Hello
I assume your problem is that the custom buttons are created multiple times. Well, then the solution is quite simple:
READ TABLE p_e_object->mt_toolbar TRANSPORTING NO FIELDS
WITH KEY function = 'OPEN'.
IF ( syst-subrc ne 0 ).
CLEAR gs_toolbar.
gs_toolbar-function = 'OPEN'.
gs_toolbar-icon = icon_status_open.
gs_toolbar-text = text-003.
gs_toolbar-butn_type = '0'.
gs_toolbar-quickinfo = text-003.
gs_toolbar-checked = space.
gs_toolbar-disabled = 'X'.
APPEND gs_toolbar TO p_e_object->mt_toolbar.
ENDIF.
Regards
Uwe
04-26-2009 9:27 PM
but when I look to the standard demo alv grid examples, he goes only one time in the event method toolbar, but when I look in my program he goes everytime in the toolbar event when I click on a button which I append to the ALV toolbar.
04-27-2009 6:24 AM
Hello
Because your ALV toolbar is indeed interactive, i.e. depending on certain conditions you want to activate or inactive buttons you need to call the HANDLE_TOOLBAR method every time you pass PBO.
If you statically add additional buttons to the ALV toolbar then you can call method go_grid->set_toolbar_interactive( ) before you display your screen. The event handler method will be called only once.
Regards
Uwe