Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problem when get current row selected by double click in control table

Hello guys, I have a problem I can get the curren row select by double click in my Control Table with code below:

WHEN 'DBCLICK'.

         clear: OK_CODE200.

         data: ws_field type string,

               ws_line type string.

       GET CURSOR FIELD ws_field LINE ws_line.

       IF ws_field(7) EQ 'WA_ALV2'.

       clear wa_alv2.

READ TABLE IT_ALV2 INTO WA_ALV2 INDEX ws_line

If the user, click on the any row when the control table is showing all  "first rows" is correct, for example in image below, user click on the first line:

I get the correct current line selected

But, when I move the scroll to down, the numerical order is modified, for example, in the image below you can see  only 3 rows, this is because I moved the scroll to down, and now I only can see 3 records, but the others records are above:

If I click on the first record displayed, my ws_line variable will have the value "1"

this is not correct, is correct only because the control table its showing only 3 records, but the other records are above, this is my problem, because when the user click on this row, my variable ws_line get the number row select, for example "1" with this number I go to my internal table for example:

READ TABLE IT_ALV2 INTO WA_ALV2 INDEX ws_line


But with this, I will get the first row of the internal table, but in my internal table I have all record not only 3 like image above:

Any one can help me?

Former Member
Former Member replied

Hii Luis

Below is sample code i used

data : ind type i.
     data : t_line type i.

     clear ind.

     t_line = zcntrl-top_line - 1.


     clear w_split.
     clear index.
     clear sy-ucomm.



     get cursor line wa_line.
     wa_line = wa_line + t_line.
     index = wa_line + 1.

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question