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: 

how to find the selected item in alv grid or table control

Former Member
0 Kudos

can any one tell me please

how to find the selected item in alv grid or table control

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

For ALV Grid, you would use the method GET_SELECTED_ROWS.



* Get Selected rows from alv grid
  CLEAR INDEX_ROWS.  REFRESH INDEX_ROWS.
  CALL METHOD ALV_GRID->GET_SELECTED_ROWS
           IMPORTING
                 ET_INDEX_ROWS = INDEX_ROWS.

Regards,

Rich Heilman

8 REPLIES 8

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

For ALV Grid, you would use the method GET_SELECTED_ROWS.



* Get Selected rows from alv grid
  CLEAR INDEX_ROWS.  REFRESH INDEX_ROWS.
  CALL METHOD ALV_GRID->GET_SELECTED_ROWS
           IMPORTING
                 ET_INDEX_ROWS = INDEX_ROWS.

Regards,

Rich Heilman

0 Kudos

Thanks very much i will try it,thanks for the instant reply

0 Kudos

Remember to award points for helpful answers. Thanks.

Regards,

Rich Heilman

Former Member
0 Kudos

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Check this link for manipulations in table control.In that,I am deleting the records selected.If you go through this link,you will get an idea to get the selected rows.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/table control in abap.pdf

Kindly reward points by clicking the star on the left of the reply if it is useful .

If you need clarifications,kindly get back.

0 Kudos

Hi,

For ALV Grid Control, one of the most comprehensive documents is, "An Easy Reference for ALV Grid Control", https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/an easy reference for alv grid control.pdf, by Serdar Simsekler.

Regards

Former Member
0 Kudos

Hi,

For ALV use cl_gui_alv_grid->get_selected_rows

importing ET_INDEX_ROWS = t_rows

t_rows will contain all the lines selected.

For Table control use

GET CURSOR LINE w_line.

w_line will contain the index of the record by which you can read the table using this index.

Former Member
0 Kudos

In table control, If you goto screen painter and goto table control properties ( f2 ), there is one check-box w/selColumn check that and give column name. Then add that column to your internal table.

IN PAI

LOOP AT it_tkhdr.

FIELD it_tkhdr-sel_row

MODULE tab_tkhdr_mark ON REQUEST.

ENDLOOP.

MODULE tab_tkhdr_mark INPUT.

MODIFY it_tkhdr INDEX tc_tkhdr-current_line.

ENDMODULE. " tab_tkhdr_mark INPUT

here it_TKHDR is internal table sel_row is field for selection

After that, you can loop at it_tkhdr where sel_row is 'X' to get selected rows.

regards,

Gagan