‎2007 Sep 13 7:17 AM
Hi all,
Can any body please tell me that in ALV grid, how can i get the drop down for insert button in the tool bar with options "Add 1", "Add 2" ... inserting 1, 2 or 3 lines??
Thanks in advance,
Kulwant
‎2007 Sep 13 8:50 AM
Check in SE38 for BCALV* or RSDEMO *
ALVOOPS
http://www.erpgenie.com/abap/controls/alvgrid.htm
https://www.sdn.sap.com/irj/sdn/wiki?path=/pages/viewpage.action&pageid=37566
/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap
http://www.sapgenie.com/abap/OO/
For understanding COntrol Frameworks in OO ABAP, check this.
http://www.sapgenie.com/abap/controls/index.htm
http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/content.htm
http://www.sapgenie.com/abap/OO/
http://www.sapgenie.com/abap/OO/index.htm
http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
http://www.sapgenie.com/abap/OO/
http://www.sapgenie.com/abap/OO/index.htm
http://www.sapgenie.com/abap/controls/index.htm
http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
http://www.sapgenie.com/abap/OO/index.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
http://www.sapgenie.com/abap/OO/
http://www.sapgenie.com/abap/OO/index.htm
http://www.geocities.com/victorav15/sapr3/abap_ood.html
http://www.brabandt.de/html/abap_oo.html
Rewards if useful...............
Minal
‎2007 Sep 13 9:05 AM
1) define following macro
DEFINE toolbar_funcs.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_TYPE.
MOVE &1 TO ls_toolbar-function.
MOVE SPACE TO ls_toolbar-disabled.
MOVE &2 TO ls_toolbar-icon.
MOVE &3 TO ls_toolbar-quickinfo.
APPEND ls_toolbar TO e_object->mt_toolbar.
END-OF-DEFINITION.
2) in the class definition
EVENTS: user_command.
METHODS:
on_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING
e_ucomm
sender,
on_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING
e_object
e_interactive.
3) define the handlers
SET HANDLER z_object->on_user_command for grid1.
SET HANDLER z_object->on_toolbar for grid1.
4) in the implementation part code the functions you've given your buttons
for example
METHOD on_user_command.
break-point 1.
CASE e_ucomm.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'EXCEL'.
CALL METHOD me->download_to_excel.
WHEN 'SAVE'.
WHEN 'PROC'.
CALL METHOD me->process.
WHEN 'REFR'.
CALL METHOD me->refresh.
ENDCASE.
ENDMETHOD. "on_user_command
In the toolbar method --use YOUR buttons and functions
Using the macro in step 1) means you have to write a lot less code. Some people don't like macros but in this case we are using it for pure code generation and not complex processing so it's (IMO) still OK.
METHOD on_toolbar.
customize this section with your own Buttons
When a button is pressed method ON_USER_COMMAND is entered
toolbar_funcs 'EXIT' icon_system_end 'Click2exit'.
toolbar_funcs 'SAVE' icon_system_save 'Savedata'.
toolbar_funcs 'EDIT' icon_toggle_display_change 'Edit data'.
toolbar_funcs 'PROC' icon_businav_process 'Process'.
toolbar_funcs 'EXCEL' icon_xxl 'Excel'.
toolbar_funcs 'REFR' icon_refresh 'Refresh'.
ENDMETHOD. "on_toolbar
Change the toolbar button type to what you want. It's all in the ALV documentation. The code above uses standard rather than drop down buttons but the process is the same.
The permitted values and types can be found by looking at the values for domain TB_BTYPE.
I think you want 2 (Menu type button).
Change this line in the macro
MOVE 0 TO ls_toolbar-butn_TYPE.
For a menu set the type to 2.
Include the menu handler in the class definition
handle_menu_button
FOR EVENT menu_button OF cl_gui_alv_grid
IMPORTING e_object e_ucomm,
SET HANDLER z_object->handle_menu_button FOR grid1.
Add your choices when you click the button
METHOD handle_menu_button.
handle own menubuttons
IF e_ucomm = 'DETAIL_MENU'.
CALL METHOD e_object->add_function
EXPORTING fcode = 'ADD1'
text = text1.
CALL METHOD e_object->add_function
EXPORTING fcode = 'ADD2'
text = text2.
ENDIF.
ENDMETHOD.
The choices (function codes from your menu) are still handled in the ON_USER_COMMAND.
Cheers
Jimbo