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 Grid - multiple selection

Former Member
0 Likes
6,611

I have created an ALV Grid the oop way. I am trying to get the selection buttons on each row to stay selected as I do not want to select individual lines while holding down Ctrl. Sel_mode in my layout table is set to A. I am using event button_click. I have used get_selected_rows in the PAI and set_selected_rows in the PBO and still I cannot get the lines to stay selected when I selected a different line.

Can anyone suggest how I can do this?

Any suggestions would be appreciated.

9 REPLIES 9
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
2,101

Did you try any of the other values for SEL_MODE?

'A'
 Column and row selection

(see graphic)
 Multiple columns 
Multiple rows
 The user selects the rows through pushbuttons at the left border of the grid control.
 
'B'
 Simple selection, list box
 Multiple columns
Multiple rows
   
'C'
 Multiple selection, list box
 Multiple columns
Multiple rows
   
'D'
 Cell selection
 Multiple columns
Multiple rows 
Any cells
 The user selects the rows through pushbuttons at the left border of the grid control

Regards,

Rich Heilman

Read only

Former Member
0 Likes
2,101

declare

data: gs_layout TYPE lvc_s_layo.

gs_layout-sel_mode = 'A'. multiple row & column selection

or you can have

gs_layout-sel_mode = 'C'. multiple selection listbox (multiple row & column selection)

CALL METHOD grid->set_table_for_first_display

EXPORTING

is_layout = gs_layout

(other export parameter)

CHANGING

it_outtab = (your itab)

it_fieldcatalog = (your fieldcat).

Read only

Former Member
0 Likes
2,101

Yes I have tried the others. What I want is upon pressing the selection button on the row, this continues to be selected until I process those lines or clear the selections. There is no checkbox field in my ALV structure so could this be my problem?

Read only

0 Likes
2,101

No, not have a checkbox in the row is not the problem. But using the checkbox in the row would probably solve your problem. The functionality built in for selecting rows is pretty standard. You have to hold down control to do muliple selection when skipping rows. This is how the gui works. Have checkboxes in your ALV grid for row selection would solved your problem.

Regards,

Rich Heilman

Read only

0 Likes
2,101

From SAP HELP PAGE

http://help.sap.com/saphelp_47x200/helpdata/en/ef/a2e9eff88311d2b48d006094192fe3/content.htm

Value

Mode

Possible selections

Comment

SPACE

same as 'B'

see 'B'

Default setting

'A'

Column and row selection

(see graphic)

Multiple columns

Multiple rows

The user selects the rows through pushbuttons at the left border of the grid control.

'B'

Simple selection, list box

Multiple columns

Multiple rows

'C'

Multiple selection, list box

Multiple columns

Multiple rows

'D'

Cell selection

Multiple columns

Multiple rows

Any cells

The user selects the rows through pushbuttons at the left border of the grid control.

CHERZ

Read only

Former Member
0 Likes
2,101

Could people please stop pasting information about the various A, B,C,D selection modes. I understand all that. I have used all that. This is being able to single click on say line 1, then line 3 and line 1 still being selected without having to use the Ctrl button to do this.

Thank you

Larissa

Read only

0 Likes
2,101

Sorry, dupplicated post.

Message was edited by:

Alejandro Bindi

Read only

0 Likes
2,101

I'm in exactly the same situation with an OO ALV. Is it possible to do what Larissa asked for? I would prefer using standard ALV selection without a checkbox (sel_mode = 'A').

You can get an example of the functionality I want anytime you get asked to activate several inactive programs at once: you can select some of them, without pressing Ctrl. But that's implemented with a Table control instead.

Or the only similar option is to implement an additional field with checkbox as Rich suggests?

In that case, how do you handle selection with checkbox? I've already declared an additional field as C, and loaded the fieldcatalog accordingly:

lwa_fieldcat-checkbox = k_true.

lwa_fieldcat-edit = k_true.

But the clickings in the checkboxes don't get reflected in the internal table behind the ALV.

Should I implement an event handler? Can you please help me out with this?

EDIT: Standard example program BCALV_EDIT_05 has this functionality using checkboxes. So post only if you know how to do what Larissa asked for in the first post.

Thank you very much.

Read only

Former Member
0 Likes
2,101

Hi Larissa Maryniuk,

I dont think button_click event is triggered once U select a row. So try to provide a field like button as the 1st field and when U click on u can use Ur previous logic of using the button_click event and in it U can set the rows as selected using set_selected_rows.One thing I am not able to understand if this happens continuously the when should the deselection happen.