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

Disbable button on alv report using oops

Former Member
0 Likes
599

Hi all,

I have a button to toll bar of alv grid using oops

based on that when the user clicks on that some action is performed and list is displayed again

now when the list is diaplyed i need the button that i added to be disabled so that the user cannot click it agin

.

i have everything i don't know how to disable the button.

USING THIS STATMENT move 'X' to ls_toolbar-disabled WE CAN DISABLE BUT I DON'T WHERE TO PASS IT..

****************************************************************

  • LOCAL CLASSES: Definition

****************************************************************

*===============================================================

  • class lcl_event_receiver: local class to

  • define and handle own functions.

*

  • Definition:

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

class lcl_event_receiver definition.

public section.

methods:

handle_toolbar

for event toolbar of cl_gui_alv_grid

importing e_object e_interactive,

handle_user_command

for event user_command of cl_gui_alv_grid

importing e_ucomm.

private section.

endclass.

*

  • lcl_event_receiver (Definition)

*===============================================================

****************************************************************

  • LOCAL CLASSES: Implementation

****************************************************************

*===============================================================

  • class lcl_event_receiver (Implementation)

*

*

class lcl_event_receiver implementation.

method handle_toolbar.

  • append a separator to normal toolbar

clear ls_toolbar.

move 3 to ls_toolbar-butn_type.

append ls_toolbar to e_object->mt_toolbar.

  • append an icon to show booking table

clear ls_toolbar.

move 'ADD' to ls_toolbar-function.

move icon_employee to ls_toolbar-icon.

move 'Show Bookings'(111) to ls_toolbar-quickinfo.

move 'Add Material'(112) to ls_toolbar-text.

move '' to ls_toolbar-disabled.

append ls_toolbar to e_object->mt_toolbar.

endmethod.

*----


method handle_user_command.

case e_ucomm.

when 'ADD'.

call method g_grid->get_selected_rows

importing et_index_rows = lt_rows.

call method cl_gui_cfw=>flush.

if sy-subrc ne 0.

  • add your handling, for example

  • call function 'POPUP_TO_INFORM'

  • exporting

  • titel = g_repid

  • txt2 = sy-subrc

  • txt1 = 'Error in Flush'(500).

else.

*tHIS IS THE PART IAM HAVING PROBLEM WITH

*class lcl_event_receiver implementation.

  • method handle_toolbar.

*clear : ls_toolbar.

loop at e_object->mt_toolbar into ls_toolbar WHERE FUNCTION = 'ADD'.

DELETE e_object->mt_toolbar FROM ls_toolbar.

move ' ' to ls_toolbar-disabled.

append ls_toolbar to e_object->mt_toolbar.

endloop.

*ENDMETHOD.

*ENDCLASS.

***tHIS IS THE PART

call method g_grid->refresh_table_display.

endif.

endcase.

endmethod.

Thanks in advance

6 REPLIES 6
Read only

Former Member
0 Likes
580

LOOP AT e_object->mt_toolbar INTO ls_toolbar.

if ls_toolbar-function = 'ADD'.

ls_toolbar-disabled = 'X'.

MODIFY e_object->mt_toolbar FROM ls_toolbar.

endif.

ENDLOOP.

Read only

former_member194669
Active Contributor
0 Likes
580

Hi,

You need to call it in set handler .


    call method grid1->set_table_for_first_display
      exporting
        is_layout                     = gs_layout
        it_toolbar_excluding          = gs_exclude
      changing
        it_outtab                     = i_yctc4[]
        it_fieldcatalog               = i_fieldcat[]
        it_sort                       = ls_sort
      exceptions
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        others                        = 4.
    if sy-subrc ne 0.
      message id sy-msgid type sy-msgty number sy-msgno
                  with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    endif.

    if event_receiver_grid is initial.
      create object event_receiver_grid.
    endif.
    set handler event_receiver_grid->handle_toolbar_0100 for grid1.
    call method grid1->set_toolbar_interactive.

aRs

Read only

Former Member
0 Likes
580

it_toolbar_excluding = gs_exclude

gs_exclude contains all buttons you wish to exclude from ALV. You will need to do a bit of research to find the name of the button and append it to gs_exclude.

Hope thi shelps.

call method grid1->set_table_for_first_display

exporting

is_layout = gs_layout

it_toolbar_excluding = gs_exclude

changing

it_outtab = i_yctc4[]

it_fieldcatalog = i_fieldcat[]

it_sort = ls_sort

exceptions

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

others = 4.

Read only

0 Likes
580

Hi

hI ALL,

MY QUESTION IS WHEN method handle_toolbaR WOULD BE TRIGERRED

first time i have the button enabled and when i press the button its get disabled.This is what i need

But iam trying to understand how this is working

Let me know whether iam right or not

when this piece of code would be triggered

method handle_toolbar.

clear ls_toolbar.

move 3 to ls_toolbar-butn_type.

append ls_toolbar to e_object->mt_toolbar.

clear ls_toolbar.

move 'ADD' to ls_toolbar-function.

move icon_employee to ls_toolbar-icon.

move 'Show Bookings'(111) to ls_toolbar-quickinfo.

move 'Add Material'(112) to ls_toolbar-text.

move ' ' to ls_toolbar-disabled.

append ls_toolbar to e_object->mt_toolbar.

IF FLAG = 'X'.

LOOP AT e_object->mt_toolbar INTO ls_toolbar.

if ls_toolbar-function = 'ADD'.

ls_toolbar-disabled = 'X'.

MODIFY e_object->mt_toolbar FROM ls_toolbar.

endif.

ENDLOOP.

ENDIF.

1 ) would this be triggered

when i call this call method g_grid->refresh_table_display.

2)or

call method g_grid->set_toolbar_interactive

This is my piece of code

class lcl_event_receiver definition.

public section.

methods:

handle_toolbar

for event toolbar of cl_gui_alv_grid

importing e_object e_interactive,

handle_user_command

for event user_command of cl_gui_alv_grid

importing e_ucomm.

private section.

endclass.

class lcl_event_receiver implementation.

method handle_toolbar.

clear ls_toolbar.

move 3 to ls_toolbar-butn_type.

append ls_toolbar to e_object->mt_toolbar.

clear ls_toolbar.

move 'ADD' to ls_toolbar-function.

move icon_employee to ls_toolbar-icon.

move 'Show Bookings'(111) to ls_toolbar-quickinfo.

move 'Add Material'(112) to ls_toolbar-text.

move ' ' to ls_toolbar-disabled.

append ls_toolbar to e_object->mt_toolbar.

IF FLAG = 'X'.

LOOP AT e_object->mt_toolbar INTO ls_toolbar.

if ls_toolbar-function = 'ADD'.

ls_toolbar-disabled = 'X'.

MODIFY e_object->mt_toolbar FROM ls_toolbar.

endif.

ENDLOOP.

ENDIF.

endmethod.

*----


method handle_user_command.

case e_ucomm.

when 'ADD'.

call method g_grid->get_selected_rows

importing et_index_rows = lt_rows.

call method cl_gui_cfw=>flush.

if sy-subrc ne 0.

else.

perform test.

call method g_grid->refresh_table_display.

endif.

endcase.

endmethod. "handle_user_command

odule status_0100 output.

  • SET PF-STATUS 'STATUS'.

set pf-status 'MAIN100'.

set titlebar 'HEADER_CHECK'.

if g_custom_container is initial.

create object g_custom_container

exporting container_name = g_container.

create object g_grid

exporting i_parent = g_custom_container.

call function 'LVC_FIELDCATALOG_MERGE'

exporting

i_structure_name = 'ZTEST'

changing

ct_fieldcat = fieldcat

exceptions

others = 3

.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

g_layout-sel_mode = 'A'. " TO GET SELECTION BOX

call method g_grid->set_table_for_first_display

exporting

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

  • I_CONSISTENCY_CHECK =

  • I_STRUCTURE_NAME =

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT = 'X'

is_layout = g_layout

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • it_toolbar_excluding = pt_exclude

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

changing

it_outtab = i_zTEST

it_fieldcatalog = fieldcat

  • IT_SORT =

  • IT_FILTER =

exceptions

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

others = 4

.

create object event_receiver.

set handler event_receiver->handle_user_command for g_grid.

set handler event_receiver->handle_toolbar for g_grid.

call method g_grid->set_toolbar_interactive.

endif. "IF grid1 IS INITIAL

call method cl_gui_control=>set_focus exporting control = g_grid.

endmodule. " STATUS_0100 OUTPUT

Thanks

Suchitra

Read only

0 Likes
580

Called at - g_grid->set_toolbar_interactive - method call

Read only

0 Likes
580

Hi,

when i press the button on the out put screen the control comes to

case e_ucomm.

when 'ADD'.

call method g_grid->get_selected_rows

importing et_index_rows = lt_rows.

call method cl_gui_cfw=>flush.

if sy-subrc ne 0.

else.

perform test..

call method g_grid->refresh_table_display. --- from here it again goes tothie code below

method handle_toolbar.

  • append a separator to normal toolbar

clear ls_toolbar.

move 3 to ls_toolbar-butn_type.

append ls_toolbar to e_object->mt_toolbar.

  • append an icon to show booking table

clear ls_toolbar.

move 'ADD' to ls_toolbar-function.

move icon_employee to ls_toolbar-icon.

move 'Show Bookings'(111) to ls_toolbar-quickinfo.

move 'Add Material'(112) to ls_toolbar-text.

move ' ' to ls_toolbar-disabled.

append ls_toolbar to e_object->mt_toolbar.

if flag = 'X'. -


This time flag is X and button gets disabled

loop at e_object->mt_toolbar into ls_toolbar.

if ls_toolbar-function = 'ADD'.

ls_toolbar-disabled = 'X'.

modify e_object->mt_toolbar from ls_toolbar.

endif.

endloop.

endif.

let me know

Thanks