cancel
Showing results for 
Search instead for 
Did you mean: 

ALV table - get row number clicked

Former Member
0 Kudos

I have a very simple ALV table in a view in my application, and need to identify the row the user selected. Could someone please tell me what method I need to use and what the code should look like to identify the selected row in the ALV? Please keep simple (I'm still learning WDA).

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

OK, I added the data declaration. My module now looks like:

METHOD onactiondelete_row .

  DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid.

  DATA lt_selected_rows TYPE lvc_t_roid .
  DATA ls_selected_row TYPE lvc_s_roid .
  <b>CALL METHOD gr_alvgrid->get_selected_rows
    IMPORTING
      et_row_no = lt_selected_rows.</b> 
  READ TABLE lt_selected_rows INTO ls_selected_row INDEX 1 .
  IF sy-subrc NE 0 .
  ENDIF.


ENDMETHOD.

I get a dump on the call method:

OBJECTS_OBJREF_NOT_ASSIGNED

Please help

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I think you should read this similar thread:

Michelle Braun has done an excellent job of detailing the row selection mechanism within Web Dynpro ABAP/ALV.

I wouldn't suggest trying to mix the SAP Gui ALV classes (cl_gui_alv_grid) along with Web Dynpro logic. Further more you are trying to use a class reference (gr_alvgrid) without every instantiating it. I would abondond this approach (as it should only be used in classic dynpro) and follow the technique that Michelle has detailed.

Answers (4)

Answers (4)

0 Kudos

Hi Bob,

Thomas is right. Your are mixing 2 different technologies.

- Michelle

Former Member
0 Kudos

Sharada K,

Your solution has me close to solving the problem.

However, you left out the data declaration, etc. for gr_alvgrid. Help anyone?

Sharadha1
Active Contributor
0 Kudos

The declaration for gr_alvgrid goes like this

DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid .

Regards,

Sharadha

Message was edited by: Sharadha K

Message was edited by: Sharadha K

Sharadha1
Active Contributor
0 Kudos

Hi,

The code to identify the selected rows in an ALV is :

DATA lt_selected_rows TYPE lvc_t_roid .

DATA ls_selected_row TYPE lvc_s_roid .

CALL METHOD gr_alvgrid->get_selected_rows

IMPORTING

et_row_no = lt_selected_rows .

READ TABLE lt_selected_rows INTO ls_selected_row INDEX 1 .

IF sy-subrc ne 0 .

ENDIF .

Hope this helps..

Regards,

Sharadha

Former Member
0 Kudos

Hi,

-


loop at r_param->t_modified_cells into ls_cell.

L_index = t_modified_cells-index.

-


(where r_param is a parameter of the event handler method created for handling ON_DATA_CHECK, L_index is your locally created variable to store the index/selected row number).

Hope this's useful!

Rgds,

Adi