Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

new button in alv tree

Former Member
0 Kudos

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

1 REPLY 1

uwe_schieferstein
Active Contributor
0 Kudos

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