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: 

Table control get selected line

Former Member
0 Kudos

Hi,

I am showing data of an internal table using table control.

Table control will show 20 rows at a time.

My internal table has 100 records.

So table control will show records in 20 rows block, when we will hit page down next 20 will come in picture.

Suppose I am showing first 20 rows and doing some changes on 10th row, by using GET CURSOR I will get 10th line as changed one, accordingly I will read my internal table of 100 records for 10th row do the necessary modification and show it in table control on that particular 10th row.

My problem is when I am doing page down next 20 rows will come into picture and in that when I am selecting 10th row which will be actually 30th row of that internal table. So while reading from that 100 records internal table I am getting incorrect data i.e I will get 10th row but actually I need 30th row.

How to solve this problem ?

Any help will be appreciable.

1 ACCEPTED SOLUTION

kesavadas_thekkillath
Active Contributor
0 Kudos

top_line + selected_line - 1 will be your selected index

4 REPLIES 4

Former Member
0 Kudos

Hi James,

Hope, you are doing in a wrong way. Just try to do as below:

1. In the internal table create a field 'SEL'.

2.Then in table control screen properties set the 'with selection column multiple option' and give this field name 'SEL'.

So that you will get an option to select the row, you want. So on selecting the same, the variable will be set. Just check whether the field is set or not to get the correct row.

Please refer the link if you want to know how to do the same - http://www.sapdev.co.uk/dialog/tabcontrol/tc_mark.htm

Regards

Selva K.

0 Kudos

Hi,

I have used table control wizard to create table control.

The field you are referring as SEL is already there in my table control as ZUSE.

But that will get activated only when I will select particular row.

Here I am not selecting row so that field will be blank.

For more details

Suppose there are 2 columns.

DECISION and GL

In decision I am having X, Y, Z, A, B, C as input drop down list, defined at data element/domain level.

Now when I will select A in DECISION column, the next column GL should get populated with 1 on the fly here user wont select row he will just select decision and next column will get populated with respective value.

mapping for DECISION and GL

A 1

B 2

C 3

X 4

Y 5

Z 6

I hope the problem is clear now.

Former Member
0 Kudos

Hi James,

Since you have used table control wizard, wizard would have created some PAI modules by default. This should be similar to the one.

top_line will store the top line of the current page. Instead of counting from the top, you should be counting the row from the new top line which should solve your issue.

module w_tctrl_userdec_user_command input.

w_ok_code = sy-ucomm.

case w_ok_code.

when 'NEXT_PAGE'.

w_tctrl_userdec-top_line = w_tctrl_userdec-top_line + w_lines.

w_limit = w_fill - w_lines + 1.

if w_tctrl_userdec-top_line > w_limit.

w_tctrl_userdec-top_line = w_limit.

endif.

when 'PREV_PAGE'.

w_tctrl_userdec-top_line = w_tctrl_userdec-top_line - w_lines.

if w_tctrl_userdec-top_line < 0.

w_tctrl_userdec-top_line = 0.

endif.

endcase.

endmodule. "w_tctrl_userdec_user_command INPUT

Cheers,

Sujay

kesavadas_thekkillath
Active Contributor
0 Kudos

top_line + selected_line - 1 will be your selected index