Application Development and Automation 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: 
Read only

set_selected_rows problem, nothing is selected

Former Member
0 Likes
2,691

Hi everybody,

I am facing a problem with an ALV and I am not able to solve. I have been looking the threads that already exist but I can not find the solution.

I am going to try to explain what is the problem:

There is an screen with some alv with tables related between them, whenever I double click in the first alv table the next table must be filled with the entries related and the entry that I double click it should be marked. The problem is any time I double click and the next alv table is open the one where I double click lost the line, I mean the focus goes to the first line of the table, meaning that the refreshing eliminates the actual selected entry.

This is what I tried to do but I don't know why it doesn't work.

1.- The lines selected are saved in a table.

CALL METHOD mo_alv_grid_edit->get_selected_rows

IMPORTING

et_index_rows = gi_index_rows.

2.- Refresh the alv table.

CALL METHOD mo_alv_grid_edit->refresh_table_display

EXPORTING

i_soft_refresh = 'X'.

3.- Set the lines I have before

CALL METHOD mo_alv_grid_edit->set_selected_rows

EXPORTING

it_index_rows = gi_index_rows .

Thanks very much

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,051

Is there a reason why you are doing a refresh ? Perhaps you can avoid a refresh and try.

BR,

Advait

17 REPLIES 17
Read only

Former Member
0 Likes
2,051

As per my understaning you have to use Get_selected_rows rather than set selected rows method.

Regards

Pavan

Read only

0 Likes
2,051

Hi Pavan,

the problem is that I lost the entries that were marked, that is the reason that befores refreshing the alv, I take from the object the lines selected and then I try to set them again after the refreshing is done.

Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
2,051

Try this :

1.- The lines selected are saved in a table.

CALL METHOD mo_alv_grid_edit->get_selected_rows

IMPORTING

et_index_rows = gi_index_rows.

call the table and then

2.- Set the lines I have before

CALL METHOD mo_alv_grid_edit->set_selected_rows

EXPORTING

it_index_rows = gi_index_rows .

Read only

0 Likes
2,051

Hi Sandeep,

what do you exactly mean with 'call the table' ?

when I call 'refresh_table_display' the outtab is update, so after this update because it is possible that new lines are added, I try to set the lines but everything is refresh so the focus come back to the first line.

Read only

0 Likes
2,051

just change the order of execution of the methods.

1 then 3 then 2

Read only

0 Likes
2,051

Hi Soumyaprakash,

I have already checked that but still doesn't work

Read only

former_member194669
Active Contributor
0 Likes
2,051

In PBO of the screen


CALL METHOD mo_alv_grid_edit->set_selected_rows
EXPORTING
it_index_rows = gi_index_rows .  " Please ensure this have values

CALL METHOD mo_alv_grid_edit->refresh_table_display. 

a®

Read only

0 Likes
2,051

Hi again,

and thanks very much to all for your help.

There is info in the table that keeps the index, but method doesn't do anything.

Read only

0 Likes
2,051

As i mentioned whether do you removed soft_refresh from refresh_table_display ?

Please check the docu on soft_refresh

http://help.sap.com/saphelp_46c/helpdata/fr/0a/b5531ed30911d2b467006094192fe3/content.htm

a®

Read only

Former Member
0 Likes
2,052

Is there a reason why you are doing a refresh ? Perhaps you can avoid a refresh and try.

BR,

Advait

Read only

0 Likes
2,051

Hi,

I have already tryed without the "refresh_table_display", but nothing happens the focus goes again to the first line.

Read only

0 Likes
2,051

But do the lines remain selected ? If they do , then try passing IS_STABLE to the REFRESH_TABLE_DISPLAY method and see. Pass the row index of the first line that was selected in gi_index_rows by reading the table at index 1.

BR,

Advait

Read only

0 Likes
2,051

the entries remain, but after the refresh they dissappear. I thought that setting this lines again it would work but nothing happens. Indeed, after setting the entries I call again get_selected_rows to be sure that something was done, and it was the entries were selected but nothing is shown in the screen, the focus goes back to the first line

Read only

0 Likes
2,051

But did you try with IS_STABLE parameter ?


*   Call the refresh
    DATA ls_stable TYPE lvc_s_stbl.
    ls_stable-row = 'X'.
    ls_stable-col = 'X'.

    CALL METHOD g_grid->refresh_table_display
      EXPORTING
        is_stable = ls_stable
      EXCEPTIONS
        finished  = 1
        OTHERS    = 2.

Now, the focus will remain on the row and column that you double clicked on.

You need to pass 'X' to the row and col field. Not the index as I had mentioned in my earlier post. Sorry about that.

BR,

Advait

Read only

0 Likes
2,051

Hi Advait,

thanks very much for all the answers

I have marked ls_stable-row = 'X'. But nothing happens the line doesn't remain, it always come back to the first line

Read only

0 Likes
2,051

Hi Advait,

thanks very much for all the answers

I have marked ls_stable-row = 'X'. But nothing happens the line doesn't remain, it always come back to the first line

Read only

0 Likes
2,051

thanks very much to all of you, after hours debugging I have found out that there was anohter refresh so everything was set up again.

I will give you the maximun points I can.

Thanks