Application Development 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: 

How to display Insert button in ALV Grid

Former Member
0 Kudos

Hi All,

When I create an ALV Grid, I dont see the Insert Row and Delete Row buttons in the toolbars by default. But when I see the class CL_GUI_ALV_GRID, I see two attributes named MC_FC_LOC_INSERT_ROW and MC_FC_LOC_DELETE_ROW. These attributes, I feel are for the insert and delete functionalities only.

Then How can we display them in our toolbar..

Please help me out.

Points are guaranteed for useful answers.

Thanks in advance.

Regards,

Himanshu

1 ACCEPTED SOLUTION

andreas_mann3
Active Contributor
0 Kudos

hi,

1) define local CLASS : DEFINITION.

   METHODS:
*for event  double click
    handle_dclick for event double_click OF cl_gui_alv_grid
            importing ES_ROW_NO,
    handle_toolbar
        FOR EVENT toolbar OF cl_gui_alv_grid
           IMPORTING e_object e_interactive.
  PRIVATE SECTION.

ENDCLASS.

2) 
implmentation:

  METHOD handle_toolbar.
* § 2.In event handler method for event TOOLBAR: Append own functions
*   by using event parameter E_OBJECT.
*   DATA: ls_toolbar  TYPE stb_button.
*....................................................................

* append a separator to normal toolbar

    CLEAR ls_toolbar.
    ls_toolbar-butn_type = 0.
    ls_toolbar-function  = 'PICK'.
    ls_toolbar-icon = ICON_MASTER_DATA_ACT.
    ls_toolbar-quickinfo = 'Debitor anzeigen'.
    ls_toolbar-disabled = space.
    APPEND ls_toolbar TO e_object->mt_toolbar.

  endmethod.


3) after creating grid

    CREATE OBJECT event_receiver.
    SET HANDLER event_receiver->handle_dclick FOR grid.
    SET HANDLER event_receiver->handle_toolbar FOR grid.

...

A.

4 REPLIES 4

andreas_mann3
Active Contributor
0 Kudos

hi,

1) define local CLASS : DEFINITION.

   METHODS:
*for event  double click
    handle_dclick for event double_click OF cl_gui_alv_grid
            importing ES_ROW_NO,
    handle_toolbar
        FOR EVENT toolbar OF cl_gui_alv_grid
           IMPORTING e_object e_interactive.
  PRIVATE SECTION.

ENDCLASS.

2) 
implmentation:

  METHOD handle_toolbar.
* § 2.In event handler method for event TOOLBAR: Append own functions
*   by using event parameter E_OBJECT.
*   DATA: ls_toolbar  TYPE stb_button.
*....................................................................

* append a separator to normal toolbar

    CLEAR ls_toolbar.
    ls_toolbar-butn_type = 0.
    ls_toolbar-function  = 'PICK'.
    ls_toolbar-icon = ICON_MASTER_DATA_ACT.
    ls_toolbar-quickinfo = 'Debitor anzeigen'.
    ls_toolbar-disabled = space.
    APPEND ls_toolbar TO e_object->mt_toolbar.

  endmethod.


3) after creating grid

    CREATE OBJECT event_receiver.
    SET HANDLER event_receiver->handle_dclick FOR grid.
    SET HANDLER event_receiver->handle_toolbar FOR grid.

...

A.

uwe_schieferstein
Active Contributor

Hello Himanshu

The INSERT and DELETE buttons will be displayed automatically for <b>editable</b> ALV grids.

If you want to set the entire ALV grid editable you can use method <b>go_grid->set_ready_for_input( '1' )</b>.

Regards

Uwe

former_member181962
Active Contributor
0 Kudos

Yes,

Uwe was right. It makes sense to have those buttons only when the grid is editable.

Check this program to know how to add buttons to the toolbar.

BCALV_GRID_05

Regards,

Ravi

Former Member
0 Kudos

Hi Experts.

The Problem is solved.

Thnx a lot for ur useful suggestions.

Regards,

Himanshu