03-12-2009 5:43 AM
Hello expert:
i added a new button in alv toolbar, but when i click the button , a system message always popup before executing subroutine. the message is ' select exactly one node'
who tell me why
your answer is appreciated
code is following
-
add Standard Button to toolbar (for Delete Subtree)
CALL METHOD mr_toolbar->add_button
EXPORTING
fcode = 'Delete'
icon = ICON_EXECUTE_OBJECT
butn_type = cntb_btype_button
text = ' Close PR'
quickinfo = 'Close PR'.
MODULE pai INPUT.
CASE ok_code.
WHEN 'EXIT' OR 'BACK' OR 'CANC'.
PERFORM exit_program.
WHEN OTHERS.
CALL METHOD cl_gui_cfw=>dispatch.
ENDCASE.
CLEAR ok_code.
CALL METHOD cl_gui_cfw=>flush.
ENDMODULE. " PAI INPUT
CLASS lcl_event_receiver IMPLEMENTATION.
delete, deselect all, select all function
METHOD function_selected.
CASE fcode.
WHEN 'DELETE'.
PERFORM close_pr.
WHEN 'UNSELALL'.
PERFORM unselect_all.
WHEN 'SELALL'.
PERFORM select_all.
ENDCASE.
ENDMETHOD.
doubleclick
METHOD function_doubleclick.
PERFORM link_me23n USING node_key fieldname.
ENDMETHOD.
ENDCLASS.
Register the event for toolbar
CREATE OBJECT go_receiver.
SET HANDLER go_receiver->function_selected FOR mr_toolbar.
SET HANDLER go_receiver->function_doubleclick FOR tree1.
Best Regards,
Kevin
i debuged the problem , when CALL METHOD cl_gui_cfw=>dispatch. execute , why program go into cl_gui_toolbar. why?
please do me a favor
03-12-2009 6:33 AM
Hello Kevin
Two ideas come into my mind:
(1) You have not selected any node in your ALV tree yet the toolbar function expects at least (exactly?) one node to be selected (NOTE: You may have selected an ITEM but not the node)
(2) Perhaps you have used NODE_SELECTION_MODE = ..._MULTIPLE in the CONSTRUCTOR method and the control expects NODE_SEL_MODE_SINGLE
Regards
Uwe