11-12-2006 10:14 AM
Hi;
i have implemented a toolbar for my ALV grid. Everytime i go back and return a copy of this icon is added on the toolbar. That means if i call the same screen ten times the same icon will be printed ten times in the toolbar. what have i missed? how can i reset?
thx
Ali
11-12-2006 10:18 AM
Hi
Past your code please?
Probably you don't refresh the table with the new icon.
Max
11-12-2006 10:18 AM
Hi
Past your code please?
Probably you don't refresh the table with the new icon.
Max
11-12-2006 10:25 AM
Hi;
This is where i set my grid (i have two grids but hte declarations are the same. i call according to a flag value(uzakdogu):
FORM alv_display .
if uzakdogu = 'X' .
*----Creating custom container instance
IF NOT gr_alvgrid IS INITIAL .
call method gr_alvgrid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
*
create object g_event_receiver type lcl_event_handler.
set handler g_event_receiver->handle_data_changed for gr_alvgrid.
set handler g_event_receiver->handle_hotspot_click for gr_alvgrid.
set handler g_event_receiver->handle_toolbar for gr_alvgrid.
set handler g_event_receiver->handle_menu_button for gr_alvgrid.
set handler g_event_receiver->handle_user_command for gr_alvgrid.
CALL METHOD gr_alvgrid->set_toolbar_interactive.
CALL METHOD gr_alvgrid->refresh_table_display.
else .
CREATE OBJECT gr_ccontainer
EXPORTING
container_name = gc_custom_control_name
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6 .
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
*----Creating ALV Grid instance
CREATE OBJECT gr_alvgrid
EXPORTING i_parent = gr_ccontainer
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5 .
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
endif .
*----Preparing field catalog.
REFRESH gt_fieldcat.
PERFORM prepare_field_catalog CHANGING gt_fieldcat .
*----Preparing layout structure
PERFORM prepare_layout CHANGING gs_layout .
ls_variant-report = sy-repid.
ls_variant-variant = '/UZAKDOGU' .
*§3.Optionally register ENTER to raise event DATA_CHANGED.
(Per default the user may check data by using the check icon).
call method gr_alvgrid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
create object g_event_receiver type lcl_event_handler.
set handler g_event_receiver->handle_data_changed for gr_alvgrid.
set handler g_event_receiver->handle_hotspot_click for gr_alvgrid.
set handler g_event_receiver->handle_toolbar for gr_alvgrid.
set handler g_event_receiver->handle_menu_button for gr_alvgrid.
set handler g_event_receiver->handle_user_command for gr_alvgrid.
CALL METHOD gr_alvgrid->set_toolbar_interactive.
CALL METHOD gr_alvgrid->set_table_for_first_display
EXPORTING
i_buffer_active = 'X'
i_bypassing_buffer = 'X'
IS_VARIANT = ls_variant
I_SAVE = 'A'
CHANGING
it_outtab = itab[]
it_fieldcatalog = gt_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
set editable cells to ready for input
CALL METHOD gr_alvgrid->set_ready_for_input
EXPORTING
I_READY_FOR_INPUT = 1.
***
else .
........
and
this routine is called everytime i call the the relevant screen because it is inside PAI of the screen.
And here are my event handler declarations:
FORM handle_toolbar USING i_object type ref to cl_alv_event_toolbar_set
P_E_INTERACTIVE.
DATA: ls_toolbar TYPE stb_button.
CLEAR ls_toolbar.
MOVE 2 TO ls_toolbar-butn_type.
MOVE 'YAZDIR' TO ls_toolbar-function.
MOVE icon_print TO ls_toolbar-icon.
MOVE 'Belge Yazdır' TO ls_toolbar-quickinfo.
MOVE 'Yazdır' TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO i_object->mt_toolbar.
ENDFORM. " handle_toolbar
************
FORM handle_menu_button USING i_object type ref to cl_ctmenu
i_ucomm type sy-ucomm.
CASE i_ucomm .
WHEN 'YAZDIR' .
CALL METHOD i_object->add_function
EXPORTING
fcode = 'ORDER'
text = 'Armatör Blg'.
CALL METHOD i_object->add_function
EXPORTING
fcode = 'INVOICE'
text = 'Muhasebe Blg.'.
ENDCASE .
ENDFORM. " handle_menu_button
*****************
FORM handle_user_command USING i_ucomm type sy-ucomm.
DATA: sonuc .
DATA: kn TYPE i.
TYPES: BEGIN OF t1,
rowtype TYPE lvc_rtype,
index TYPE lvc_index,
END OF t1.
DATA: lt_rows TYPE lvc_t_row,
xrow TYPE t1.
DATA: pi_objky TYPE na_objkey,
xkappl TYPE na_kappl.
IF i_ucomm EQ 'ORDER'.
xkappl = 'V1'.
ELSE.
xkappl = 'V3'.
ENDIF.
if not uzakdogu is initial.
CALL METHOD gr_alvgrid->get_selected_rows
IMPORTING
et_index_rows = lt_rows.
else.
CALL METHOD gr_alvgrid2->get_selected_rows
IMPORTING
et_index_rows = lt_rows.
endif.
DESCRIBE TABLE lt_rows LINES kn.
IF kn GT 0.
READ TABLE lt_rows INTO xrow INDEX 1.
READ TABLE itab INDEX xrow-index .
CHECK xrow-rowtype EQ ''.
IF sy-subrc EQ 0.
IF i_ucomm EQ 'ORDER'.
MOVE itab-cnv_arm_belge TO pi_objky.
IF pi_objky EQ ''.
MESSAGE s020(zdhmsg).
RETURN.
ENDIF.
ELSE.
MOVE itab-cnv_mhs_belge TO pi_objky.
IF pi_objky EQ ''.
MESSAGE s021(zdhmsg).
RETURN.
ENDIF.
ENDIF.
IF pi_objky NE ''.
CALL FUNCTION 'RV_MESSAGE_DIALOG'
EXPORTING
pi_kappl = xkappl
pi_objky = pi_objky
EXCEPTIONS
cancel = 1
message_not_printable = 2
no_message = 3
print_error = 4
preview_error = 5
invalid_preview_mode = 6
OTHERS = 7.
ENDIF.
ENDIF.
ELSE.
MESSAGE s020(zdhmsg).
ENDIF.
ENDFORM. " handle_user_command
11-12-2006 10:29 AM
Hi
FORM handle_toolbar USING i_object type ref to cl_alv_event_toolbar_set P_E_INTERACTIVE.
DATA: ls_toolbar TYPE stb_button.
REFRESH i_object->mt_toolbar. "<---------- Try to refresh this table
CLEAR ls_toolbar.
MOVE 2 TO ls_toolbar-butn_type.
MOVE 'YAZDIR' TO ls_toolbar-function.
MOVE icon_print TO ls_toolbar-icon.
MOVE 'Belge Yazdır' TO ls_toolbar-quickinfo.
MOVE 'Yazdır' TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO i_object->mt_toolbar.
ENDFORM. " handle_toolbar
Max
11-12-2006 10:45 AM
Hi;
now all standard buttons are gone and still the menu entries of the icon keep repeating themselves.
Regards
Ali
11-12-2006 10:53 AM
Sorry!
Try this:
FORM handle_toolbar USING i_object type ref to cl_alv_event_toolbar_set
P_E_INTERACTIVE.
DATA: ls_toolbar TYPE stb_button.
READ TABLE I_OBJECT->MT_TOOLBAR INTO LS_TOOLBAR WITH KEY FUNCTION = 'YAZDIR'.
CHECK SY-SUBRC <> 0.
CLEAR ls_toolbar.
MOVE 2 TO ls_toolbar-butn_type.
MOVE 'YAZDIR' TO ls_toolbar-function.
MOVE icon_print TO ls_toolbar-icon.
MOVE 'Belge Yazdır' TO ls_toolbar-quickinfo.
MOVE 'Yazdır' TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO i_object->mt_toolbar.
ENDFORM. " handle_toolbar
Max
11-12-2006 10:58 AM
Hi;
it worked . Thx a lot )
i have the same problem with sub menus now. i have twooptions under the icon and they keep on repeating themselves. which table of the object should i check?
code for adding sub menus is like following:
FORM handle_menu_button USING i_object type ref to cl_ctmenu
i_ucomm type sy-ucomm.
CASE i_ucomm .
WHEN 'YAZDIR' .
CALL METHOD i_object->add_function
EXPORTING
fcode = 'ORDER'
text = 'Armatör Blg'.
CALL METHOD i_object->add_function
EXPORTING
fcode = 'INVOICE'
text = 'Muhasebe Blg.'.
ENDCASE .
ENDFORM. " handle_menu_button
Regards
Ali
11-12-2006 11:20 AM
Hi
I'm not sure but I believe you can check which functionalities are loaded by method
get_function:
DATA: TCODES TYPE UI_FUNCATTR.
CASE i_ucomm .
WHEN 'YAZDIR' .
CALL METHOD i_object->get_function
IMPORTING
FCODES = TCODES.
READ TABLE TCODES WITH KEY FCODE = 'ORDER' TRANSPORTING NO FIELDS.
IF SY-SUBRC <> 0.
CALL METHOD i_object->add_function
EXPORTING
fcode = 'ORDER'
text = 'Armatör Blg'.
ENDIF.
READ TABLE TCODES WITH KEY FCODE = 'INVOICE' TRANSPORTING NO FIELDS.
IF SY-SUBRC <> 0.
CALL METHOD i_object->add_function
EXPORTING
fcode = 'INVOICE'
text = 'Muhasebe Blg.'.
ENDIF.
Max