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

button in grid toolbar

Former Member
0 Likes
898

Hi frnds,

I have a doubt like i want to add button named "delete" in the toolbar of alvgrid.

so i have taken the class cl_gui_toolbar and picked the method "add_button".

in the top include i have declared like

delete_button type ref to cl_gui_toolbar.

and when i called the method add_button using the instance delete_button.

so i got like this.

<code>

call method delete_button->add_button

exporting

fcode =

icon =

  • IS_DISABLED =

butn_type =

  • TEXT =

  • QUICKINFO =

  • IS_CHECKED =

  • EXCEPTIONS

  • CNTL_ERROR = 1

  • CNTB_BTYPE_ERROR = 2

  • CNTB_ERROR_FCODE = 3

  • others = 4

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

</code>

Frnds i m in doubt what shuld i pass in the parameters like

fcode =

icon =

butn_type =

i am in dielima that shuld be create any button in the grid or not.

please reply frnds.

Thanks

satya

Message was edited by:

satya ranjan

3 REPLIES 3
Read only

Former Member
0 Likes
665

Hi,

Here is the code to add a button to ALV grid

call screen 100.

*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

  • class lcl_event_receiver: local class to

  • define and handle own functions.

*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

class lcl_event_receiver definition.

public section.

methods:

*>>>>> Method to handle tool bar

handle_toolbar

for event toolbar of cl_gui_alv_grid

importing e_object e_interactive,

*>>>>> Method to handle user command sy-ucomm

handle_user_command

for event user_command of cl_gui_alv_grid

importing e_ucomm.

private section.

endclass.

*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

$$$$$$$$$$$ class lcl_event_receiver(Implementation)$$$$$$

*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

class lcl_event_receiver implementation.

*>>>>> Method to handle tool bar

method handle_toolbar.

*>>>>> using button as Separator

clear ls_toolbar.

move 3 to ls_toolbar-butn_type.

append ls_toolbar to e_object->mt_toolbar.

clear ls_toolbar.

*>>>>> Assign a sy-ucomm to button

move 'DELE' to ls_toolbar-function.

*>>>>> To add image on the button

move icon_material to ls_toolbar-icon.

*>>>>> To add the desc to button

move 'Delete'(112) to ls_toolbar-text.

*>>>>> To leave button enabled

move ' ' to ls_toolbar-disabled.

append ls_toolbar to e_object->mt_toolbar.

*>>>>> To make the button disabled if pressed already

if flag = 'X'.

loop at e_object->mt_toolbar into ls_toolbar.

if ls_toolbar-function = 'DELE'.

*>>>>> To leave button disabled

ls_toolbar-disabled = 'X'.

modify e_object->mt_toolbar from ls_toolbar.

endif.

endloop.

test1 = 'X'.

endif.

endmethod.

let me know if you still having any issues

Thanks

Venki

Read only

RaymondGiuseppi
Active Contributor
0 Likes
665

Look at <a href="http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf">ALV Gird Control (BC-SRV-ALE)</a>

Process Flow
1. Define an event handler method for event TOOLBAR.
2. Declare a structure for defining a toolbar element:
data: ls_toolbar TYPE stb_button.
3. For a pushbutton, for example, you would fill the following fields:
CLEAR ls_toolbar. 
MOVE 0 TO ls_toolbar-butn_type. 
MOVE 'BOOKINGS' TO ls_toolbar-function. 
MOVE icon_employee TO ls_toolbar-icon.
MOVE 'Show Bookings'(111) TO ls_toolbar-quickinfo. 
MOVE SPACE TO ls_toolbar-disabled.
In the butn_type field, you specify the type of the GUI element for the ALV Grid Control. For possible values, see the value range of domain TB_BTYPE.
4. Use event parameter E_OBJECT to append the new definition to table mt_toolbar:
APPEND ls_toolbar TO e_object->mt_toolbar.
5. If you want to define additional elements, go back to step 3.
6. Call method set_toolbar_interactive [Page 103], if you want to rebuild the toolbar.

Look also at demo program <b>BCALV_GRID_05</b>

Regards

Read only

Former Member
0 Likes
665

hi

good

Adds a new button to the toolbar

CALL METHOD go_toolbar->add_button

EXPORTING fcode = 'EXIT' "Function Code for button

icon = icon_system_end "ICON name, You can use type pool ICON

is_disabled = ' ' "Disabled = X

butn_type = gc_button_normal "Type of button, see below

text = 'Exit' "Text on button

quickinfo = 'Exit program' "Quick info

is_checked = ' '. "Button selected

Toolbar button types used in method ADD_BUTTON:

http://72.14.235.104/search?q=cache:3zJHVrsiesoJ:www.erpgenie.com/abap/controls/toolbar.htmcallmethod+delete_button,SAP&hl=en&ct=clnk&cd=1&gl=in

reward point if helpful.

thanks

mrutyun^