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: 

how to deactive a button in application toolbar

Former Member
0 Kudos

how to deactive a button in application toolbar?

1 ACCEPTED SOLUTION

sivasatyaprasad_yerra
Active Contributor

Hi,

We can disable the button in PBO of the screen. Invoke SET PF-STATUS as follows:

DATA: toolbar_func_disable TYPE ui_functions,

wa_toolbar_func_disable TYPE ui_func.

wa_toolbar_func_disable = 'DELE'. " Function code of the button

APPEND wa_toolbar_func_disable TO toolbar_func_disable.

SET PF-STATUS 'Your tool bar name GUI status' EXCLUDING toolbar_func_disable.

This will disable the button in the menu bar.

Reward points if useful.

Regards,

Siva.

10 REPLIES 10

Former Member
0 Kudos

Hi,

take the pf-status, go to se41 there remove the function code for the required button .save and activate.

Rgds.,

subash

0 Kudos

i mean to say.. it shud get deactivated based on some event...

EX: i have one button on the app..toolbar, named "ABC"

this ABC button shud not b highlighted (ie. it sud b deactivated) automatically when im in the last page...something like that....

raymond_giuseppi
Active Contributor
0 Kudos

Look at thread

Regards

Former Member
0 Kudos

Simple example

This example shows how to create a toolbar with a single Exit button, used to exit the program.

Steps:

Create a screen and add a custom container named TOOLBAR_CONTAINER

Code:

REPORT sapmz_hf_toolbar .

TYPE-POOLS: icon.

CLASS cls_event_handler DEFINITION DEFERRED.

  • G L O B A L D A T A

DATA:

ok_code LIKE sy-ucomm,

  • Reference for conatiner

go_toolbar_container TYPE REF TO cl_gui_custom_container,

  • Reference for SAP Toolbar

go_toolbar TYPE REF TO cl_gui_toolbar,

  • Event handler

go_event_handler TYPE REF TO cls_event_handler.

  • G L O B A L T A B L E S

DATA:

  • Table for registration of events. Note that a TYPE REF

  • to cls_event_handler must be created before you can

  • reference types cntl_simple_events and cntl_simple_event.

gi_events TYPE cntl_simple_events,

  • Workspace for table gi_events

g_event TYPE cntl_simple_event.

----


  • CLASS cls_event_handler DEFINITION

----


  • ........ *

----


CLASS cls_event_handler DEFINITION.

PUBLIC SECTION.

METHODS:

on_function_selected

FOR EVENT function_selected OF cl_gui_toolbar

IMPORTING fcode,

on_dropdown_clicked

FOR EVENT dropdown_clicked OF cl_gui_toolbar

IMPORTING fcode posx posy.

ENDCLASS.

----


  • CLASS cls_event_handler IMPLEMENTATION

----


  • ........ *

----


CLASS cls_event_handler IMPLEMENTATION.

METHOD on_function_selected.

CASE fcode.

WHEN 'EXIT'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDMETHOD.

METHOD on_dropdown_clicked.

  • Not implented yet

ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.

SET SCREEN '100'.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE status_0100 OUTPUT.

IF go_toolbar_container IS INITIAL.

  • Create container

CREATE OBJECT go_toolbar_container

EXPORTING

container_name = 'TOOLBAR_CONTAINER'.

  • Create toolbar

CREATE OBJECT go_toolbar

EXPORTING

parent = go_toolbar_container.

  • Add a button

CALL METHOD go_toolbar->add_button

EXPORTING fcode = 'EXIT' "Function Code

icon = icon_system_end "ICON name

is_disabled = ' ' "Disabled = X

butn_type = cntb_btype_button "Type of button

text = 'Exit' "Text on button

quickinfo = 'Exit program' "Quick info

is_checked = ' '. "Button selected

  • Create event table. The event ID must be found in the

  • documentation of the specific control

CLEAR g_event.

REFRESH gi_events.

g_event-eventid = go_toolbar->m_id_function_selected.

g_event-appl_event = 'X'. "This is an application event

APPEND g_event TO gi_events.

g_event-eventid = go_toolbar->m_id_dropdown_clicked.

g_event-appl_event = 'X'.

APPEND g_event TO gi_events.

  • Use the events table to register events for the control

CALL METHOD go_toolbar->set_registered_events

EXPORTING

events = gi_events.

  • Create event handlers

CREATE OBJECT go_event_handler.

SET HANDLER go_event_handler->on_function_selected

FOR go_toolbar.

SET HANDLER go_event_handler->on_dropdown_clicked

FOR go_toolbar.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

http://www.erpgenie.com/abap/controls/toolbar.htm#Simple%20example

http://help.sap.com/saphelp_nw04/helpdata/EN/42/d2ab343e416635e10000000a1553f6/content.htm

help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCITOOLBAR/BCCITOOLBAR.pdf

Regards,

Jagadish

sivasatyaprasad_yerra
Active Contributor

Hi,

We can disable the button in PBO of the screen. Invoke SET PF-STATUS as follows:

DATA: toolbar_func_disable TYPE ui_functions,

wa_toolbar_func_disable TYPE ui_func.

wa_toolbar_func_disable = 'DELE'. " Function code of the button

APPEND wa_toolbar_func_disable TO toolbar_func_disable.

SET PF-STATUS 'Your tool bar name GUI status' EXCLUDING toolbar_func_disable.

This will disable the button in the menu bar.

Reward points if useful.

Regards,

Siva.

Former Member
0 Kudos

Hi Srk's

Plz refer the below link

http://web.mit.edu/SAPR3/docs/webdocs/getstarted/gsSCREENS.html

You can use Excluding command for pf status.

Eg.

If sy-subrc ne 0.

set pf-status '9000' excluding 'SAVE'.

endif.

or.

DATA:

itab TYPE TABLE OF sy-datar,

wa LIKE LINE OF itab.

wa = 'SAVE'.

APPEND wa TO itab.

wa = 'CANCEL'.

APPEND wa TO itab.

SET PF-STATUS '9000' EXCLUDING itab.

plz rewards points if helpful,

Ganesh.

Former Member
0 Kudos

Hi,

Try this.

Here, depens on the user menu will be changed.

if User1 enters, then save and change will be deactivated.

If User2, then they will be in active status only.

DATA : fcode TYPE TABLE OF sy-ucomm.

APPEND 'CHANGE' TO fcode.

APPEND 'SAVE' TO fcode.

PAI.

module mod_name.

module mod_name.

case sy-uname.

when 'USER1'.

SET PF-STATUS 'STATUS_0100' EXCLUDING fcode.

WHEN 'USER2'.

SET PF-STATUS 'STATUS_0100' .

ENDCASE.

endmodule.

Regards

Sandeep REddy

Former Member
0 Kudos

Thanks to one and all. My query is answered.

Former Member
0 Kudos

Hi,

do like this initially set pf-status to default one. then when ever u want to display or hide the button in application toolbar. Take a variable for pf-status as per the logic u pass the value to set pf-status.

Ex : set pf-status zstatus

logic:

zstatus = DEFAULT.

.........

....

zstatus = STATUS.

If u do like this , when ever PBO triggers u can display or hide the button as per ur requirement . just i am giving an rough idea hope u understand this.

0 Kudos

Hi Subhash

Are DEFAULT and STATUS are the constants that u used, as provided by SAP..??