Application Development 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: 

CL_GUI_ALV_GRID select a row

Former Member
0 Kudos

I need to get selected rows from my alv grid .

I need to handle and event or introduce a selection field on my internal table?

Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi jorge,

check this link:

http://www.sapgenie.com/abap/controls/alvgrid.htm

reward if helpful.

regards,

kerthi.

8 REPLIES 8

andreas_mann3
Active Contributor

hi,

use method CL_GUI_ALV_GRID->GET_SELECTED_ROWS

sample:

DATA rows TYPE lvc_t_row.
  DATA wa_row TYPE lvc_s_row.

  CALL METHOD grid->get_selected_rows
     IMPORTING
       et_index_rows = rows.

  LOOP AT rows INTO wa_row.
  ...

Andreas

Message was edited by: Andreas Mann

Former Member
0 Kudos

Hi Jorge,

try this...

DATA: IT_ORDERS_SELECTED TYPE ZAUTO_T_T_ORDERS,

WA_SELECTED_ROW TYPE LVC_S_ROID.

*--getting the selected row indexes

CALL METHOD OBJ_GRID_DETAIL->GET_SELECTED_ROWS

IMPORTING

ET_ROW_NO = IT_SELECTED_ROWS.

this table will have all the row numbers selected

*--loop through the selected rows to get the row no's

REFRESH IT_ORDERS_SELECTED.

LOOP AT IT_SELECTED_ROWS INTO WA_SELECTED_ROW.

....write the logic here like reading the internal table with index WA_SELECTED_ROW-ROW_ID....

ENDLOOP.

Regards,

Vidya.

Former Member
0 Kudos

Hi jorge,

check this link:

http://www.sapgenie.com/abap/controls/alvgrid.htm

reward if helpful.

regards,

kerthi.

0 Kudos

With the method GET_SELECTED_ROWS obtain the selected rows.

Mi answer is how to select rows ,how we create the buttons for selecting rows by the final user .

do I need to use something more ?

0 Kudos

You can set the SELECTION MODE to 'D' in the layout.

LAYOUT-SEL_MODE = 'D'.

Then you can call the GET_SELECTED_ROWS method.

Regards,

Ravi

Note : Please mark all the helpful answers

0 Kudos

Hi Jorge,

User can selet the rows by selecting the box which comes as first column in ALV GRId

or

u can use a check box in internal table and user can check then and u can loop at itab where checkbox = 'X' to get the selected records

0 Kudos

Hi,

pass layout paramaters like below :

DATA : x_layout TYPE lvc_s_layo.

x_layout-sel_mode = 'A'.

Pass x_layout to method 'set_table_for_first_display'.

CALL METHOD x_grid->set_table_for_first_display

EXPORTING

i_save = 'A'

is_layout = x_layout

output of the ALV will contain buttons

Regards

Appana

Former Member
0 Kudos

Hi Jorge,

try this....

set the X_LAYOUT-SEL_MODE = 'C'. (this will enable you to select multiple rows)...

now pass this layout ...

CALL METHOD OBJ_GRID_DETAIL->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

IS_LAYOUT = X_LAYOUT

IS_VARIANT = X_VARIANT

I_SAVE = 'A'

CHANGING

IT_FIELDCATALOG = IT_FLDCAT_DETAILS

IT_OUTTAB = 'table to be displayed'

hope this helps..

Regards,

Vidya