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: 

Reg..Application Tool bar in ALV

Former Member
0 Kudos

I am using ALV report,using classes by default it displays a tool-bar below the main tool bar.

I want to disable all the buttons on this tool-bar, how can we disable all this buttons.

3 REPLIES 3

Former Member
0 Kudos

Hi MS,

this might help,

*&----


*

*& 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

Mohinder

Former Member
0 Kudos

Hi

Go through the link given below :

With Regards

Nikunj Shah

Former Member
0 Kudos

Hi MS Kumar.

I would like to suggest a couple of references,

[SDN - Reference - Disable some standard buttons from ALV display |;

[SDN - Reference - Change toolbar in ALV in runtime |;

Hope that's usefull.

Good Luck & Regards.

Harsh Dave