2007 Mar 07 5:06 AM
How can we create a push-button in ALV-GRID.
How will u handle a push-button in ALV.
2007 Mar 07 5:10 AM
Hi,
GO to SE41 copy the status STANDARD from the program SAPLKKBL..And give the status name and your program name.
In the parameter I_CALLBACK_PF_STATUS_SET give the form name 'PF_STATUS_SET'.
In the subroutine.
FORM PF_STATUS_SET.
SET PF-STATUS 'STATUS NAME THAT YOU GAVE IN SE41'.
ENDFORM.
For user command pass the parameter I_CALLBACK_USER_COMMAND with the user command subroutine name..
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
...
IF R_UCOMM = ''.
...
ENDIF.
ENDFORM.
Example
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = lv_repid
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS_SET'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
............
Thanks,
Naren
2007 Mar 07 5:51 AM
Hello,
To add a push button and handle it,you have to define a local class and use the methods <b>handle_toolbar</b> and <b>handle_user_command</b>.Here is a sample code:
----
CLASS lcl_eh DEFINITION
----
*
----
CLASS lcl_eh DEFINITION.
PUBLIC SECTION.
DATA:
<b>ls_toolbar TYPE stb_button</b>.
METHODS:
<b>handle_toolbar</b>
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
<b>handle_user_command</b>
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS. "lcl_eh DEFINITION
***********************************************************************
*Type referencing an object of the class
***********************************************************************
<b>DATA: lo_obj TYPE REF TO lcl_eh.</b>
----
CLASS lcl_eh IMPLEMENTATION
----
*
----
CLASS lcl_eh IMPLEMENTATION.
***********************************************************************
*METHOD: HANDLE_TOOLBAR
*DESCRIPTION: This method provides the necessary detail required to
create an extra button in the toolbar.
***********************************************************************
METHOD <b>handle_toolbar.</b>
CLEAR ls_toolbar.
MOVE 'CREATE' TO ls_toolbar-function.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'CREATE' TO ls_toolbar-text.
MOVE 'ICON_DETAIL' TO ls_toolbar-icon.
MOVE 'CREATE' TO ls_toolbar-quickinfo.
<b>APPEND ls_toolbar TO e_object->mt_toolbar.</b>
ENDMETHOD. "handle_toolbar
***********************************************************************
*METHOD: HANDLE_USER_COMMAND
*DESCRIPTION: This method is used to handle the push button
***********************************************************************
<b>METHOD handle_user_command.</b>
<b> CASE e_ucomm.</b>
<b> WHEN 'CREATE'.</b>
**logic
...
ENDCASE.
ENDMETHOD.
ENDCLASS.
Regards,
Beejal
**reward if this helps
2007 Mar 09 10:16 PM
Hello Ajay
Assuming that you want to have a "push-button" column, i.e. push-buttons <b>within</b> an ALV grid then you need to implement the following steps:
(1) Set the style of the column as button
ls_fcat-style = CL_GUI_ALV_GRID => MC_STYLE_BUTTON.
(2) When the user pushes the button event <b>BUTTON_CLICK</b> is triggered. Thus, define an appropriate event handler method.
Regards
Uwe
2007 Mar 10 5:09 AM
Hi Ajay Do this way. you just copy this and modify according to your naming conventions.
TOP INCLUDE
-
CLASS event_handler_class DEFINITION.
PUBLIC SECTION.
METHODS:
Toolbar Event for Fund ALV
handle_alv_toolbar_prod FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object,
*
Handling ALV Grids toolbar buttons
handle_user_command_prod FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm,
Handling ALV Grids toolbar buttons
handle_user_command_region FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm,
ENDCLASS.
DATA:
gp_handler TYPE REF TO event_handler_class.
FORM INCLUDE
-
CLASS event_handler_class IMPLEMENTATION.
METHOD handle_alv_toolbar_prod.
PERFORM handle_product_toolbar USING e_object . "e_interactive.
ENDMETHOD. "handle_ar_toolbar
METHOD handle_user_command_prod.
PERFORM handle_user_command_prod USING e_ucomm.
ENDMETHOD. "handle_user_command
ENDCLASS
Form
-
FORM handle_product_toolbar USING
p_object TYPE REF TO cl_alv_event_toolbar_set.
*
Adding Buttons to Toolbar
DATA: ls_toolbar TYPE stb_button.
*
Adding 'Select All' Button on the toolbar
CLEAR ls_toolbar.
MOVE 'SELECT_ALL' TO ls_toolbar-function.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'Select All' TO ls_toolbar-text.
MOVE icon_create TO ls_toolbar-icon.
MOVE 'Select All' TO ls_toolbar-quickinfo. " Select All
APPEND ls_toolbar TO p_object->mt_toolbar . "INDEX 1.
ENDFORM.
In the form Hndle User Command you write you own code.
FORM handle_user_command_prod USING p_ucomm TYPE sy-ucomm.
*
IF p_ucomm = 'SELECT_ALL'.
LOOP AT gt_product INTO gs_product.
gs_product-product_check = 'X'.
MODIFY gt_product FROM gs_product TRANSPORTING product_check.
CLEAR: gs_product.
ENDLOOP.
ENDIF.
ENDORM.
you write this code before Set table for first display.
SET HANDLER gp_handler->handle_user_command_prod FOR gp_alv_grid_prod.
SET HANDLER gp_handler->handle_alv_toolbar_prod FOR gp_alv_grid_prod.
2007 Mar 12 7:57 AM
hi ajay..
check this link and read the 'An Easy Reference for ALV Grid Control' pdf file.
<a href="http://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/advancedsearch?query=an%20easy%20reference%20for%20alv%20grid%20control&cat=sdn_all">http://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/advancedsearch?query=an%20easy%20reference%20for%20alv%20grid%20control&cat=sdn_all</a>
i hope it will be helpful to you.
regards,
Jalendhar