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

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

Former Member
0 Likes
4,744

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?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,605

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.

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.

10 REPLIES 10
Read only

Former Member
0 Likes
4,605

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

Read only

0 Likes
4,605

Could you please give me more information? I can't understand what's "Page fown for scrolling"

Read only

Former Member
0 Likes
4,605

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

Read only

Former Member
0 Likes
4,606

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.

Read only

0 Likes
4,603

Hello Gaurav, I have a question refer to your code, in this line:      t_line = zcntrl-top_line - 1. "zcntrl" is my control table name? I wirte this code on my  MODULE user_command_0200. but I have the error below:

My control table name is: tbc2. but as you can see I get an error where SAP says tbc2-TOP_LINE does not exist.

Could you please tell me if  the place where I did write  my code is correct?

Read only

0 Likes
4,603

Hi Luis,

How did you define your table control?


CONTROLS: tbc2   TYPE TABLEVIEW USING SCREEN 1000.

Read only

0 Likes
4,602

Hello Archana,

I used the  WIZARD:

Read only

0 Likes
4,602

Hi Luis,

In your screenshot you can see line,

tbc2-current line.

If you are able to access that you should be able to access top_line as well.

You can double click on tbc2, it will take you to the declaration of table control.

Read only

0 Likes
4,601

Yes, I can see my definition

But I have follow error:

Read only

0 Likes
4,601

I solved my problem, I moved CONTROLS: TBC2 TYPE TABLEVIEW USING SCREEN 0200. to my Top Inclide.