Application Development and Automation 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: 
Read only

Graying a button (Enable)

MusAbaper
Active Participant
0 Likes
3,021

Hi everyone,

I have 1 status (with 2 buttons) for 2 different screens:

For the first screen, I need a button and graying hair another. And contrary to the second screen.

Can you give me a source code that enables graying (Enable) of a button.

Thank you.

Sincerely.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,509

HI,

use

set pf-status 'MENU' excluding 'FCODE'.

rgds,

bharat.

8 REPLIES 8
Read only

Former Member
0 Likes
2,510

HI,

use

set pf-status 'MENU' excluding 'FCODE'.

rgds,

bharat.

Read only

0 Likes
2,509

Hi,

I want the button is disabled not exclude it.

thanks

Read only

0 Likes
2,509

HI,

if u use excluding the button in menu or standard toolbar will be grayed out if it is in application toolbar it will be disappeared.

to make the application toolbar buttons appear and grayed out goto to the screen painter and select ur STATUS in change mode.there next to application toolbar section u will find out an icon.if u click on that,u will get a pop-up window in that select the radio button DISPLAY ALL and press OK button and then activate the menu.

rgds,

bharat.

Read only

0 Likes
2,509

Sorry, but i want just that the button ==> desabled not hide it.

regards

Read only

0 Likes
2,509

just use this source like this :

include your bouton in group exemple 'BT'

loop at screen

if group = 'BT'

nambuton-activ = 0

modify screen

endloop.

Read only

0 Likes
2,509

I can make a LOOP AT SCREEN even though this is a button from the menu bar?

regards

Read only

0 Likes
2,509

Thank you a lootttttttt, ur answer is very very helpful

==> this what is miss ====> u will get a pop-up window in that select the radio button DISPLAY ALL and press OK button and then activate the menu

thank you again

Best regards

Mustapha

Read only

Former Member
0 Likes
2,509

hi please try the following code given below,

The following sample reports shows how to disable toolbar functions. Run the report and the push the ENTER button repeatedly.

*&----


*

*& Report ZUS_SDN_ALV_EVT_TOOLBAR

*&

*&----


*

*& This sample report explains the handling of event TOOLBAR in order

*% to activate or inactive buttons of the ALV toolbar.

*&

*& Based on: BCALV_GRID_DEMO

*&

*& Procedure: Copy BCALV_GRID_DEMO and replace entire coding OR

  • copy screen '0100' and GUI status 'MAIN100' from

  • BCALV_GRID_DEMO to this report.

*&----


*

REPORT zus_sdn_alv_evt_toolbar.

TYPE-POOLS: abap, cntb, icon.

DATA:

ok_code TYPE ui_func,

gt_sflight TYPE TABLE OF sflight,

*

g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',

g_grid1 TYPE REF TO cl_gui_alv_grid,

g_custom_container TYPE REF TO cl_gui_custom_container.

PARAMETERS:

p_inact RADIOBUTTON GROUP grp1 DEFAULT 'X', " delete buttons

p_dele RADIOBUTTON GROUP grp1. " inactivate buttons

PARAMETERS:

p_newbut AS CHECKBOX DEFAULT ' ', " add new button

p_newddm AS CHECKBOX DEFAULT 'X'. " add dropdown menu

*----


*

  • CLASS lcl_eventhandler DEFINITION

*----


*

*

*----


*

CLASS lcl_eventhandler DEFINITION.

PUBLIC SECTION.

CLASS-DATA:

md_cnt TYPE i.

CLASS-METHODS:

handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid

IMPORTING

e_object

e_interactive

sender.

ENDCLASS. "lcl_eventhandler DEFINITION

*----


*

  • CLASS lcl_eventhandler IMPLEMENTATION

*----


*

*

*----


*

CLASS lcl_eventhandler IMPLEMENTATION.

METHOD handle_toolbar.

  • § 2.In event handler method for event TOOLBAR: Append own functions

  • by using event parameter E_OBJECT.

DATA:

ls_toolbar TYPE stb_button,

ls_menu type STB_BTNMNU.

*....................................................................

  • E_OBJECT of event TOOLBAR is of type REF TO CL_ALV_EVENT_TOOLBAR_SET.

  • This class has got one attribute, namly MT_TOOLBAR, which

  • is a table of type TTB_BUTTON. One line of this table is

  • defined by the Structure STB_BUTTON (see data deklaration above).

*

  • A remark to the flag E_INTERACTIVE:

  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  • 'e_interactive' is set, if this event is raised due to

  • the call of 'set_toolbar_interactive' by the user.

  • You can distinguish this way if the event was raised

  • by yourself or by ALV

  • (e.g. in method 'refresh_table_display').

  • An application of this feature is still unknown...

ADD 1 TO md_cnt. " a simple counter

  • (1.a) Inactivate toolbar buttons

IF ( p_inact = abap_true ).

LOOP AT e_object->mt_toolbar INTO ls_toolbar FROM 1 TO md_cnt.

ls_toolbar-disabled = 'X'.

MODIFY e_object->mt_toolbar FROM ls_toolbar.

ENDLOOP.

  • (1.b) Delete toolbar buttons

ELSE.

DO md_cnt TIMES.

DELETE e_object->mt_toolbar INDEX 1.

ENDDO.

ENDIF.

  • (2) Add new button

IF ( p_newbut = abap_true ).

  • Add separator to separate default and new buttons

CLEAR: ls_toolbar.

ls_toolbar-butn_type = cntb_btype_sep. " separator

APPEND ls_toolbar TO e_object->mt_toolbar.

  • Add new button "DETAIL"

CLEAR: ls_toolbar.

ls_toolbar-function = 'DETAIL'.

ls_toolbar-icon = icon_detail.

ls_toolbar-quickinfo = 'QuickInfo'.

ls_toolbar-butn_type = cntb_btype_button.

ls_toolbar-disabled = abap_false.

ls_toolbar-text = 'Details'.

  • ls_toolbar-checked = ' '.

APPEND ls_toolbar TO e_object->mt_toolbar.

ENDIF.

  • (3) Add new dropdown menu

IF ( p_newddm = abap_true ).

  • Add separator to separate default and new buttons

CLEAR: ls_toolbar.

ls_toolbar-butn_type = cntb_btype_sep. " separator

APPEND ls_toolbar TO e_object->mt_toolbar.

  • Add new dropdown menu "DETAIL"

CLEAR: ls_toolbar.

ls_toolbar-function = 'DDMENU'.

ls_toolbar-icon = icon_detail.

ls_toolbar-quickinfo = 'QuickInfo'.

ls_toolbar-butn_type = cntb_btype_dropdown.

ls_toolbar-disabled = abap_false.

ls_toolbar-text = 'DD-Menu'.

  • ls_toolbar-checked = ' '.

APPEND ls_toolbar TO e_object->mt_toolbar.

ENDIF.

ENDMETHOD. "handle_toolbar

ENDCLASS. "lcl_eventhandler IMPLEMENTATION

START-OF-SELECTION.

*----


*

  • MAIN *

*----


*

SELECT * FROM sflight INTO TABLE gt_sflight.

CALL SCREEN 100.

END-OF-SELECTION.

*----


*

  • MODULE PBO OUTPUT *

*----


*

MODULE pbo OUTPUT.

SET PF-STATUS 'MAIN100'.

IF g_custom_container IS INITIAL.

CREATE OBJECT g_custom_container

EXPORTING container_name = g_container.

  • Instantiate ALV grid control

CREATE OBJECT g_grid1

EXPORTING i_parent = g_custom_container.

CALL METHOD g_grid1->set_table_for_first_display

EXPORTING

i_structure_name = 'SFLIGHT'

CHANGING

it_outtab = gt_sflight.

  • Set event handler for event TOOLBAR

SET HANDLER:

lcl_eventhandler=>handle_toolbar FOR g_grid1.

ENDIF.

  • $Comment: Toolbar can be modified on-the-fly

g_grid1->set_toolbar_interactive( ).

ENDMODULE. "PBO OUTPUT

*----


*

  • MODULE PAI INPUT *

*----


*

MODULE pai INPUT.

  • to react on oi_custom_events:

CALL METHOD cl_gui_cfw=>dispatch.

CASE ok_code.

WHEN 'EXIT'.

PERFORM exit_program.

WHEN OTHERS.

  • do nothing

ENDCASE.

CLEAR ok_code.

ENDMODULE. "PAI INPUT

*----


*

  • FORM EXIT_PROGRAM *

*----


*

FORM exit_program.

  • CALL METHOD G_CUSTOM_CONTAINER->FREE.

  • CALL METHOD CL_GUI_CFW=>FLUSH.

LEAVE PROGRAM.

ENDFORM. "EXIT_PROGRAM

Reward points if usefull,

Thanks and regards,

kalyan.