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 OOPS ALV

Former Member

Dear Friends,

I need your valuable expertise on OOPS ALV.

I am using OOPS ALV. The output is displayed as required.

The user then sorts the output by a particular column or multiple columns using the standard sort button on ALV GRID.

Then he is selecting a particular row on the new output. This is how he wants to proceed.

Then I am using get_selected_rows when the user presses a custom button which returns the index according to the new view, which is fine.

However, I only have my internal table which is not sorted.

Using the index in the Get_Selected_Rows doesnot help.

Is there a way to get the complete record or any other method to find the record which the user selects.

Kindly help.

Thank you,

Ishaq.

1 ACCEPTED SOLUTION

Former Member

For OOPs ALV , For the screen where you have defined the container for ALV,

IN PAI call this method

CALL METHOD e_grid->check_changed_data .

Then you call the method

CALL METHOD e_grid->get_selected_rows

IMPORTING

et_index_rows = t_selected_rows.

the internal table t_selected_rows contains indexes of the rows selected.

6 REPLIES 6

Former Member
0 Kudos

Hi,

u can insert a new field in to the internal table like SEL. when the row is selected u can mark that filed as X for that row.

this way u can know which rows have been selected. that u can handle with the event in data change.

is that what u r asking for?

regards,

pavan.

Former Member

For OOPs ALV , For the screen where you have defined the container for ALV,

IN PAI call this method

CALL METHOD e_grid->check_changed_data .

Then you call the method

CALL METHOD e_grid->get_selected_rows

IMPORTING

et_index_rows = t_selected_rows.

the internal table t_selected_rows contains indexes of the rows selected.

0 Kudos

Its really the perfect answer.

So get the editable value after alv display by oops alv is after

call method grid->set_table_for_first_display (data : grid type ref to cl_gui_alv_grid)

Then in PAI only call the method

CALL METHOD e_grid->check_changed_data . (data : e_grid type ref to cl_gui_alv_grid )


only this much of code thn u ll get your value...I did and i got the answer...


Thanks

Former Member
0 Kudos

Hi,

I wil send u the sample code u just try managing ur code this way

gr_salv_table type ref to cl_salv_table

gr_selections type ref to cl_salv_selections

gt_rows type salv_t_row

gr_selections = gr_salv_table->get_selections( ).

gt_rows = gr_selections->get_selected_rows( ).

gt_rows will contain the selected rows.

0 Kudos

Hi,

Use this code for Registering the values in alv to internal table

* Registering edit
  CALL METHOD g_alvgd->register_edit_event
    EXPORTING
      i_event_id = cl_gui_alv_grid=>mc_evt_modified.

the purpose of the register edit is to capture your grid and store the values in your internal table itself.

after that use the below code for the Selected Rows,

  CALL METHOD g_alvgd->get_selected_rows
    IMPORTING
      et_index_rows = it_selected_rows.
  IF it_selected_rows IS INITIAL.
    MESSAGE text-m01 TYPE 'I'.
  ELSE.

after this loop the it_selected_rows and do your code to achieve the output............ hope you are looking for this !!!