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: 

Get selected rows in ALV grid using method:GET_SELECTED_ROWS

Former Member
0 Kudos

Hello Guys,

I would required to get the selected rows in ALV grid using method:GET_SELECTED_ROWS.

How to get it resolve this issue.

Thank&Regards,

Rpn.Reddy

13 REPLIES 13

Former Member
0 Kudos

Hi,

Any idea on the below mentioned query?

Regards,

Rpn.Reddy

Former Member
0 Kudos

Hi,

I have written the below logic to get the selected rows in the ALV grid but its giving dump.

ATA: i_rowindex TYPE lvc_t_row.

data:gv_alvgrid2 TYPE REF TO cl_gui_alv_grid.

CALL METHOD gv_alvgrid2->get_selected_rows

IMPORTING

et_index_rows = i_rowindex.

Any idea on this?

Regards,

Rpn

0 Kudos

Hi,

what dump it is giving ? and are u using reuse_alv FM to display alv ?

Former Member
0 Kudos

Hi,

I am getting the following dump:OBJECTS_OBJREF_NOT_ASSIGNEDu201D.

Yes I am using this FM:'REUSE_ALV_GRID_DISPLAY' to display the ALV report.

Regards,

Rpn

0 Kudos

Hi,

then the get_selected row will not work .. Exactly what u want to do ? do u want the selected row in user command event ?

then u will get the tabindex of the line selected as shown below

FORM ucom USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

IF rs_selfield-fieldname = 'D07'. --> this will give the field name

READ TABLE it_day INDEX rs_selfield-tabindex. ---> this will give the selected row

endif.

endformucom.

Former Member
0 Kudos

There are, no doubt, hundreds of posts regarding use of ALV. Please search the forum.

There is also SAP Documentation on ALV, but classic and OO, and should you develop an interest in using current technology in SAP, there is a wealth of information on NetWeaver ALV (aka SALV).

There are also a large number of programs available for review, named like BCALV*. For instance, look at BCALV_GRID_08 for user command handling.

Former Member
0 Kudos

Hi,

Yes ,I wanted the selected rows in the user-command event.user may select one or multiple rows in report.

Reagrds,

Rpn

0 Kudos

Hi to all.

I think you have a field indicated as checkbox (field LAYOUT-BOX_FIELDNAME).

If you haven't determinated, it cannot be multiple choices, so on Selected field of user command form (field SLIS_SELFIELD-TABINDEX).

If you have determinated it, is needed to select all rows of your internal table where the field indicated is marcked.

I think this could help you.

Former Member
0 Kudos

Hi,

I have used the check box for each record in the report.Its working correctly when I select the rows for the first time.Once I come back to the screen report and I choose other record in the report,it is not displaying for the second selected record but it still displaying the report for previous selected row only.

My requirement is once we back to the report screen and choose other rows,it should display the report only for the selected rows,it should not display for the previous selected row.

Any idea on this?

Regards,

Reddy

0 Kudos

Can you post here the code for User_Command event?

this could help us to find the error.

Former Member
0 Kudos

Hi,

Find the below logic which i have written in my program to get the selected rows.

Here IT_RPT is the internal table for the first report screen.

IT_FINAL is the internal table for the second report screen.

DATA : ref_grid TYPE REF TO cl_gui_alv_grid. " new

CLEAR it_rpt.

IF ref_grid IS INITIAL.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = ref_grid.

ENDIF.

  • Replace table with modifications...

IF NOT ref_grid IS INITIAL.

CALL METHOD ref_grid->check_changed_data.

ENDIF.

DELETE it_rpt WHERE chkbox IS INITIAL.

IF NOT it_rpt[] IS INITIAL.

clear it_final. refresh it_final.

SELECT matnr b_werk b_lager typbz sernr

serge charge lifnr "DV1K942921

FROM v_equi_eqbs_sml

INTO CORRESPONDING FIELDS OF TABLE it_final

FOR ALL ENTRIES IN it_rpt

WHERE matnr = it_rpt1-matnr

AND b_werk = it_rpt1-werks

AND b_lager = it_rpt1-lgort

and lifnr = it_rpt1-lifnr

  • AND b_lager IN s_lgort "DV1K942921

AND charge IN s_charg.

ENDIF.

Regards,

Rpn

Former Member
0 Kudos

Hi All,

Any idea on this.

Regards,

Reddy

0 Kudos

Free the container instead of using refresh_grid_display

CALL METHOD OBJ_R_CONTAINER->FREE.
   CALL METHOD CL_GUI_CFW=>FLUSH.