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

After user command is added tool disappeared

Former Member
0 Likes
1,617

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?

1 ACCEPTED SOLUTION
Read only

DoanManhQuynh
Active Contributor
1,482

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?

4 REPLIES 4
Read only

DoanManhQuynh
Active Contributor
1,483

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)).
Read only

0 Likes
1,482

I see that you have the same issues as I have with spaces removed from code by SCN 🙂

Read only

0 Likes
1,482

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.

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,482