‎2007 Jun 27 12:01 PM
Hi Guys
My requirement is this
In my ALV output,i created 2 buttons select and deselect,
When i select select all button,then all rows should be selected and deslect button all rows should be deselected,
Can anyone provide me how to proceed on that.
Thanks
‎2007 Jun 27 12:06 PM
Set the selection mode as Multi in your ALV. The select and deselect toggle button will come automatically. Why do you want to implement it separately?
‎2007 Jun 27 12:11 PM
‎2007 Jun 27 12:14 PM
Assuming you are using the old alv class CL_GUI_ALV_GRID, declare a variable for your layout of type lvc_s_layo.
In lvc_s_layo, you have a field sel_mode. Set this to 'A' for multiple selection. Hope this helps. Let me know if you are using the new ALV cl_salv_table, it would be different then.
Award points if it solves your problem.
Regards,
Nithya
‎2007 Jun 27 12:23 PM
My code like this
*object for custom container
DATA : g_custom_container
TYPE REF TO cl_gui_custom_container,
*object for alv grid
sap_grid
TYPE REF TO cl_gui_alv_grid.
*layout for ALV grid
DATA: g_layout TYPE lvc_s_layo,
g_save TYPE c,
wa_fcat TYPE lvc_s_fcat.
CREATE OBJECT g_custom_container
EXPORTING
PARENT =
container_name = 'SUB_AREA'
CREATE OBJECT sap_grid
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
i_parent = g_custom_container
CALL METHOD sap_grid->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
i_structure_name = 't_final'
IS_VARIANT =
i_save = g_save
i_default = 'X'
is_layout = g_layout
MODULE user_command_1200 INPUT.
MOVE ok_code TO save_ok_code.
CLEAR ok_code.
CALL METHOD cl_gui_cfw=>dispatch.
CASE save_ok_code.
WHEN 'SAVE'.
CALL METHOD sap_grid->check_changed_data.
PERFORM grid_refresh.
*on BACK leave program
WHEN 'BACK'.
CALL METHOD g_custom_container->free.
CALL METHOD cl_gui_cfw=>flush.
CLEAR g_custom_container.
CLEAR sap_grid.
LEAVE TO SCREEN 0.
EXIT.
Thanks
‎2007 Jun 27 12:29 PM
Before calling set_table_for_first_display, write g_layout-sel_mode = 'A'.
You will see a button on the top left corner of your ALV grid, which is for select all and deselect all.
‎2007 Jun 27 12:54 PM
Hi Anyway iam getting that now also
i want to write in user command for my buttons.
Thanks
‎2007 Jun 27 1:01 PM
Ok! In the class cl_gui_alv_grid, you have a method set_selected_rows. Use that to set your rows as selected. You need to get the row count of the internal table that you have bound to the ALV table and pass each row index. Each row will get selected then.
‎2007 Jun 27 12:06 PM
just skim the methods of the class CL_GUI_ALV_GRID.
i´m quite sure there should be a method select_all, deselect_all. or with some similar name.
well if not, you gotta do it by hand. Loop at screen, and either set or remove the flag of the field selkz.