2019 Jan 08 4:02 PM
Hi all
I have a ALV grid in a modal dialog that looks as following:

I tried to add tool bar to the ALV as following:
The event class :
CLASS lcl_evt_task_user_cmd IMPLEMENTATION.
METHOD handle_toolbar.
e_object->mt_toolbar = VALUE ttb_button(
( butn_type = 3 )
( function = 'EDIT' icon = icon_edit_file butn_type = 0 )
).
ENDMETHOD.
METHOD handle_user_command.
CASE e_ucomm.
WHEN 'EDIT'.
ENDCASE.
* cl_gui_cfw=>set_new_ok_code('DUMMY').
ENDMETHOD.
ENDCLASS.and the way how I added:
METHOD show.
FIELD-SYMBOLS <lt_table> TYPE STANDARD TABLE.
IF c_go_provider->c_go_grid IS INITIAL.
DATA(lt_fieldcat) = me->get_fieldcat( c_go_provider->c_gv_struname ).
c_go_provider->c_go_container = NEW cl_gui_custom_container( container_name = co_grid_name ).
c_go_provider->c_go_grid = NEW cl_gui_alv_grid( i_parent = c_go_provider->c_go_container ).
ASSIGN c_go_provider->c_gt_data->* TO <lt_table>.
me->register_event( ).
c_go_provider->c_go_grid->set_table_for_first_display(
EXPORTING
is_variant = VALUE disvariant( report = sy-repid )
i_save = 'A'
is_layout = VALUE lvc_s_layo( sel_mode = 'A' )
CHANGING
it_outtab = <lt_table>
it_fieldcatalog = lt_fieldcat
).
c_go_provider->c_go_grid->set_toolbar_interactive( ).
ENDIF.
c_go_provider->c_go_grid->refresh_table_display( ).
ENDMETHOD.
METHOD register_event.
me->c_go_event = NEW lcl_evt_task_user_cmd( ).
SET HANDLER me->c_go_event->handle_toolbar
me->c_go_event->handle_user_command
FOR c_go_provider->c_go_grid.
ENDMETHOD.
After, the standard toolbar disappeared:

What am I doing wrong?
2019 Jan 09 12:17 AM
its disappeared because you overwrite the mt_toobar:
e_object->mt_toolbar =VALUE ttb_button(( butn_type =3)(function='EDIT'icon= icon_edit_file butn_type =0)).you should add, not overwrite:
e_object->mt_toolbar =VALUE ttb_button( BASE ( e_object->mt_toolbar ) ( butn_type =3)(function='EDIT'icon= icon_edit_file butn_type =0)).
Hi all
I have a ALV grid in a modal dialog that looks as following:

I tried to add tool bar to the ALV as following:
The event class :
CLASS lcl_evt_task_user_cmd IMPLEMENTATION.
METHOD handle_toolbar.
e_object->mt_toolbar = VALUE ttb_button(
( butn_type = 3 )
( function = 'EDIT' icon = icon_edit_file butn_type = 0 )
).
ENDMETHOD.
METHOD handle_user_command.
CASE e_ucomm.
WHEN 'EDIT'.
ENDCASE.
* cl_gui_cfw=>set_new_ok_code('DUMMY').
ENDMETHOD.
ENDCLASS.and the way how I added:
METHOD show.
FIELD-SYMBOLS <lt_table> TYPE STANDARD TABLE.
IF c_go_provider->c_go_grid IS INITIAL.
DATA(lt_fieldcat) = me->get_fieldcat( c_go_provider->c_gv_struname ).
c_go_provider->c_go_container = NEW cl_gui_custom_container( container_name = co_grid_name ).
c_go_provider->c_go_grid = NEW cl_gui_alv_grid( i_parent = c_go_provider->c_go_container ).
ASSIGN c_go_provider->c_gt_data->* TO <lt_table>.
me->register_event( ).
c_go_provider->c_go_grid->set_table_for_first_display(
EXPORTING
is_variant = VALUE disvariant( report = sy-repid )
i_save = 'A'
is_layout = VALUE lvc_s_layo( sel_mode = 'A' )
CHANGING
it_outtab = <lt_table>
it_fieldcatalog = lt_fieldcat
).
c_go_provider->c_go_grid->set_toolbar_interactive( ).
ENDIF.
c_go_provider->c_go_grid->refresh_table_display( ).
ENDMETHOD.
METHOD register_event.
me->c_go_event = NEW lcl_evt_task_user_cmd( ).
SET HANDLER me->c_go_event->handle_toolbar
me->c_go_event->handle_user_command
FOR c_go_provider->c_go_grid.
ENDMETHOD.
After, the standard toolbar disappeared:

What am I doing wrong?
2019 Jan 09 12:17 AM
its disappeared because you overwrite the mt_toobar:
e_object->mt_toolbar =VALUE ttb_button(( butn_type =3)(function='EDIT'icon= icon_edit_file butn_type =0)).you should add, not overwrite:
e_object->mt_toolbar =VALUE ttb_button( BASE ( e_object->mt_toolbar ) ( butn_type =3)(function='EDIT'icon= icon_edit_file butn_type =0)).
2019 Jan 09 9:55 AM
I see that you have the same issues as I have with spaces removed from code by SCN 🙂
2019 Jan 10 12:21 AM
yes, space removed will happend when we copy text inside code tag from other answer (comment). I have been experience it for a few times.
2019 Jan 09 9:53 AM
Question also asked on stackoverflow: https://stackoverflow.com/questions/54099836/after-user-command-is-added-tool-disappeared
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |