10-01-2008 8:03 AM
10-01-2008 8:27 AM
Hi,
Do like this:
1) in layout structure set selection mode for multiple rows
ls_layout-sel_mode = 'A'.
2) then just call this method
call method alv->get_selected_rows importing et_row_no = lt_rows.
The parameter u201Cet_row_nou201D is of type LVC_T_ROID and returns row indexes for selected rows (but not cells or columns) in it.
Regards
Marcin
10-01-2008 8:05 AM
10-01-2008 8:22 AM
10-01-2008 8:06 AM
You may use get cursor for a single row and accordingly modify the flag corresponding to that row and thus for each selection the internal table is populated with the flag checked.
And then on the basis of the flag u can make the selection.
10-01-2008 8:20 AM
10-01-2008 8:22 AM
Hi,
Get the Selected record.
data : w_grid_cont type ref to cl_gui_container.
data : w_alv type ref to cl_gui_alv_grid.
create object w_alv
exporting
i_parent = w_grid_cont.
call method w_alv->check_changed_data.
Select Multiple record.
Loop at itab.
itab-xflag = 'X'.
modify itab.
endloop.
Try this Method,
Thanks,
Durai.V
Edited by: Durai V on Oct 1, 2008 9:23 AM
10-01-2008 8:27 AM
Hi,
Do like this:
1) in layout structure set selection mode for multiple rows
ls_layout-sel_mode = 'A'.
2) then just call this method
call method alv->get_selected_rows importing et_row_no = lt_rows.
The parameter u201Cet_row_nou201D is of type LVC_T_ROID and returns row indexes for selected rows (but not cells or columns) in it.
Regards
Marcin
10-01-2008 8:37 AM
10-01-2008 8:51 AM
Please ensure you are passing ls_layout to set_table_for_first_display method.
Where do you call GET_SELECTED_ROWS ?
10-01-2008 8:53 AM
HI
YES I AM PASSING IS_LAYOUT IN SET_FIRST_DISPLAY..... DO I NEED TO CALL GET_SELECTED ROWS ALSO
10-01-2008 9:01 AM
Yes, you have to. Otherwise you won't be able to know which rows were selected.
It is best to use it in AT USER-COMMAND event block.
AT USER-COMMAND.
if sy-ucomm = "here your fcode for some pushbutton like i.e. GET_NO_ROWS
call method alv->get_selected_rows importing et_row_no = lt_rows.
endif.
Setting layout to 'A' value is just indicating that multipy rows selection can be performed,
but the activity of gettting selected rows itself is different and must be explicitly used (by calling the method get_selected_rows).
BR
Marcin
10-01-2008 9:44 AM
hi
i did ls_layout-sel_mode = 'A'.
as well as i caleed method get selected data but its not getting anyrows filled in t_rows...
thank u
10-01-2008 9:53 AM
hi
i am able to select only single row n am able to get the index of that row using gt_select_data ......
but i need for multiple selection i folowed what u said that is V_LAYOUT-SEL_MODE = 'A'.
can u plz guide me for multiple row selection
thank u
10-01-2008 9:57 AM
Please give us your code. Maybe it will be easier to help you then.
10-01-2008 10:02 AM
V_LAYOUT TYPE LVC_S_LAYO,
V_LAYOUT-SEL_MODE = 'A'.
V_LAYOUT-zebra = 'X'.
V_LAYOUT-EDIT = 'X'.
V_LAYOUT-NO_TOOLBAR = 'X'.
V_LAYOUT-GRID_TITLE = 'stock in warehouse'.
CALL METHOD GRID2->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
IS_LAYOUT = V_LAYOUT
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
CHANGING
IT_OUTTAB = IT_FINAL_RAW
IT_FIELDCATALOG = IT_FIELDCAT1
IT_SORT =
IT_FILTER =
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
others = 4
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE PROGRAM.
when 'OPTIMIZE'.
data : it_rows type LVC_T_ROID..
CALL METHOD GRID2->GET_SELECTED_ROWS
IMPORTING
ET_INDEX_ROWS =
ET_ROW_NO = it_rows
.
10-01-2008 10:19 AM
10-01-2008 10:27 AM
One point to notice here is that if you set your ALV Grid as to be editable, it may override your selection mode regardless of your layout settings. Please try with removing edit mode from layout structure.
10-01-2008 10:30 AM
10-01-2008 10:34 AM
hi marcin,
i added checkboxes to each row and atleast can we capture the row indexes which are selected using the check boxes
10-01-2008 10:35 AM
Hmm, strange to me, I have very similar code and it works fine. Maybe try different selection modes. Use either u2018Cu2019 or u2018Du2019 as they both work with get_selected_rows method.
10-01-2008 10:41 AM
10-01-2008 10:46 AM
10-01-2008 11:01 AM
HI,
I SAW THE LINK..I HAV DONE ACCORDING TO IT BUT STILL ITS NOT WORKING........CAN U SUGEST ME THE SOLUTION FOR
...............................................i added
checkboxes to each row and atleast can we capture the row indexes which are selected using the check boxe
10-01-2008 11:17 AM
10-01-2008 11:40 AM
Hi urmila,
I did a check with your code. I tweaked it a bit to use standard SFLIGHT table and it is working.
Don't look at that parts where SFLIGHT is used.
DATA: v_layout TYPE lvc_s_layo,
grid2 TYPE REF TO cl_gui_alv_grid.
DATA: it_final_raw TYPE STANDARD TABLE OF sflight. "here an example output table
START-OF-SELECTION.
"you don't use this, it's for my usage
SELECT * FROM sflight INTO TABLE it_final_raw.
CREATE OBJECT grid2
EXPORTING
i_parent = cl_gui_container=>screen0.
"here is your code
v_layout-sel_mode = 'A'.
CALL METHOD grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT' "populate fieldcatalog instead of SFLIGHT (as you do this in your code)
is_layout = v_layout
CHANGING
it_outtab = it_final_raw.
CALL SCREEN '0100'.
*----------------------------------------------------------------------*
* MODULE STATUS_0100 OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS space.
ENDMODULE. "STATUS_0100 OUTPUT
*----------------------------------------------------------------------*
* MODULE USER_COMMAND_0100 INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
"select your desired rows as shown in the screenshot link below the code
"then hit back button
WHEN 'BACK'.
DATA : it_rows TYPE lvc_t_roid..
CALL METHOD grid2->get_selected_rows
IMPORTING
et_row_no = it_rows.
"here you will get all marked rows in it_rows table
ENDCASE.
ENDMODULE. "USER_COMMAND_0100 INPUT
http://myworld.hekko.pl/alv.JPG
Sorry for being trival but sometimes it is only way for solving an issue.
It is working fine for me so it must work for you too.
BR
Marcin