2005 Nov 10 10:39 AM
hi All,
I am using the following context menus in 2 screens. 2 screens are having 2 custom containers and their names are identical in both the screens. there are 5 buttons required in first screen, whereas the second screen doesn't requires a button. i.e., it requires only 4 buttons.
now, what i want is to invisible the button when i enter into the second screen. and it should visible in first screen. how to do this. plz help.
IF go_toolbar_container IS INITIAL.
Create container
CREATE OBJECT go_toolbar_container
EXPORTING
container_name = 'MY_CONTAINER'.
Create toolbar
CREATE OBJECT go_toolbar
EXPORTING
parent = go_toolbar_container.
Add a button
CALL METHOD go_toolbar->add_button
EXPORTING fcode = 'SEL'
icon = icon_select_detail
is_disabled = ' '
butn_type = cntb_btype_button
text = 'Exit' "Text on button
quickinfo = 'Select Periods'
is_checked = ' '.
Add a seperator
IF w_scr_num NE '0103'.
CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
EXPORTING
fcode = 'SEP1'
icon = ' '
disabled = 'X'
butn_type = cntb_btype_sep
CHANGING
data_table = gi_button_group.
CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
EXPORTING fcode = 'INS'
icon = icon_insert_row
disabled = ''
butn_type = cntb_btype_button
quickinfo = 'Insert Row'
checked = ' '
CHANGING
data_table = gi_button_group.
Add a seperator
CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
EXPORTING
fcode = 'SEP2'
icon = ' '
disabled = 'X'
butn_type = cntb_btype_sep
CHANGING
data_table = gi_button_group.
CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
EXPORTING fcode = 'DEL'
icon = icon_delete_row
disabled = ' '
butn_type = cntb_btype_button
quickinfo = 'Delete Row'
checked = ' '
CHANGING
data_table = gi_button_group.
Add a seperator
CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
EXPORTING
fcode = 'SEP3'
icon = ' '
disabled = 'X'
butn_type = cntb_btype_sep
CHANGING
data_table = gi_button_group.
CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
EXPORTING fcode = 'SALL'
icon = icon_select_all
disabled = ' '
butn_type = cntb_btype_button
quickinfo = 'Select All'
checked = ' '
CHANGING
data_table = gi_button_group.
Add a seperator
CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
EXPORTING
fcode = 'SEP4'
icon = ' '
disabled = 'X'
butn_type = cntb_btype_sep
CHANGING
data_table = gi_button_group.
CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
EXPORTING fcode = 'DALL'
icon = icon_deselect_all
disabled = ' '
butn_type = cntb_btype_button
quickinfo = 'Deselect All'
checked = ' '
CHANGING
data_table = gi_button_group.
Add button group to toolbar
CALL METHOD go_toolbar->add_button_group
EXPORTING data_table = gi_button_group.
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.
ENDIF.
2005 Nov 10 10:46 AM
Hi Ateeq,
When you goto screen 200, in the PBO write code
to delete buttons from screen.
CALL METHOD MR_TOOLBAR->DELETE_BUTTON
EXPORTING
FCODE = FCODE
But becareful when you are using same containers in both the screens. Some time it may go to dump.
Hopw this will help you.
Thanks & Regards,
Siri
2005 Nov 10 11:54 AM
I had already checked with the delete button. the button is deleted in both screens. also when i return back for the second time in screen 2 it goes to dump. i need to check avoid this. any help
2005 Nov 10 12:14 PM
Hi Ateeq,
Because you are using same containers in the two screens, it is going to dump.
Please let me know whether you are doing check like
if the container is initial then only you create instace for it.So for the first time it will do next time onwards you need to create container object.
in the second screen alos need not to create container object you can directly use it.
Instead of delete button use visible method to do invisible / visible in screen 2.
Hope this info will help you.
Thanks & Regards,
Siri.
2005 Nov 14 7:18 AM
hi all,
Thanx for ur replies... i am using the set_visible in order to make the visible false for the pushbuttons.
but the whole toolbar is disabled.
CALL METHOD go_toolbar->set_visible
EXPORTING visible = temp_vis.
Please help me how to do the invisible mode true for the first pushbutton.
Also i had used the delete_button and add_button property in order to make the pushbutton visibility false. but the button is added at the last in the toolbar. i need to have this at the first.
Please help me.
2005 Nov 14 8:51 AM
Hi Ateeq,
To insert the button in the first position. Try the below code.
CLEAR LS_TOOLBAR.
MOVE 'CHANGE' TO LS_TOOLBAR-FUNCTION.
MOVE ICON_CHANGE TO LS_TOOLBAR-ICON.
MOVE 'Change'(111) TO LS_TOOLBAR-QUICKINFO.
MOVE ' ' TO LS_TOOLBAR-DISABLED.
INSERT LS_TOOLBAR INTO E_OBJECT->MT_TOOLBAR
INDEX 1.
Please try this hope it will help you.
Thanks & Regards,
Siri.
2005 Nov 14 9:56 AM
Hi srilatha,
Thanx for ur reply.
But the code is not working. i am not writing the code for the alv. i am using the context menus in dynpro.
Any other suggestions...is always welcome
2005 Nov 10 11:10 AM
Hi,
I think you can also use cl_gui_toolbar -> SET_VISIBLE. Before you must check the atribute VISIBLE_TRUE.
Regards,
Mireia