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

ALV Select

Former Member
0 Likes
941

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

8 REPLIES 8
Read only

Former Member
0 Likes
893

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?

Read only

0 Likes
893

Hi

Can you eloborate on this plz??

Thanks

Read only

0 Likes
893

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

Read only

0 Likes
893

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

Read only

0 Likes
893

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.

Read only

0 Likes
893

Hi Anyway iam getting that now also

i want to write in user command for my buttons.

Thanks

Read only

0 Likes
893

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.

Read only

Former Member
0 Likes
893

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.