Skip to Content
avatar image
Former Member

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?

primera linea.PNG (70.3 kB)
linea.PNG (9.1 kB)
rows.PNG (55.4 kB)
Captura.PNG (26.2 kB)
Captura.PNG (20.8 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Jan 03, 2015 at 07:02 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 02, 2015 at 07:44 AM

    Hi Roberto,

    i guess you are doing scroll down by using mouse right, instead of doing like use page down for scrolling controll table then you will get expected result.

    Thanks,

    Sree

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 03, 2015 at 07:01 AM

    Hii Luis

    Try to get top line of you table control (table control name-top_line) and then try to find out your line index.

    Regards

    Gaurav

    Add comment
    10|10000 characters needed characters exceeded