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

Table control: Line selection single issue

former_member192842
Participant
0 Likes
7,155

Hi experts,

I have created a table control and in the screen painter I have defined the line selection as "Single" for table control.

The table control can display upto 20 lines in a screen and i can select a single record only which pertains to my requirement. if I try to select two records it will not allow.

Issue: consider  i select a single record from the first 20 lines displayed in screen, then i scroll the records in the table control so that it displays the records from 21 to 40. if I select a single record now from line 21 to 40, the first record that i selected is not getting deselected. That is, totally two lines are getting selected.

How to overcome this issue

Thanks in advance

Regards

Anand

15 REPLIES 15
Read only

Former Member
0 Likes
5,226

Did you do the following?

Read only

0 Likes
5,226

yes i marked line selection as single in screen painter attributes.

As i mentioned in above mail. the single selection is not working fine during scrolling only.

Example. Say below is the records displayed in table control and i select the  2nd record

1. A

2. B

3. C

Now i scroll the table control and the records now displayed in table control are below.

3. C

4. D

5. E

Now if i select the record 4 and scroll above, the record 2 is still selected. Thus now in the table control i have 2 records selected even though i have defined single selection in screen painter.

Regards

Anand

Read only

0 Likes
5,226

I build a program and did the above selection and it only allows me to select 1 row on a screen. If you try and select multiple rows on the same screen it doesn't allow. Further as in your e.g. if I select 2B and scroll down and select 4D then 2B is no longer selected...

Try checking the demo program provided by SAP  RSDEMO_TABLE_CONTROL..

can you share the screen shots when both the lines are selected.

Regards

Read only

Former Member
0 Likes
5,226

Hi,

I had faced the same problem.

1. Write a module in the PAI of screen(inside loop-endloop). There you write code to deselect all the rows(i.e. clear the "column selection" field of the internal table for all rows).

What happens with this is both the rows selected in tab control will be removed.

2. Then write FIELD-MODULE statement on this "column selection" field in PAI(inside loop-endloop) so that the latest selected field gets updated.

Hope it helps.

Sumit

Read only

Former Member
0 Likes
5,226

Hi

You need to clear the marker field for all record not shown in table control

You can know which records loaded in your table control:

- the first one in TOP_LINE, the last one can be calculated by system variable SY-LOOPC

Max

Read only

former_member192842
Participant
0 Likes
5,225

Hi Experts,

1. I maintained the line selection as single for row

2. Then PAI of the screen, inside the table control loop endloop the following code was written to update the selected record in the internal table of table control. wa_indet is the structure of table control and wa_indet-sel is the selection field table control.

Note: Once i update the sel value in internal table in PAI, Im not clearing sel value anywhere, because of which the line will be selected even in PBO. Only way to clear the sel value is, user has to manually deselect the selected record or select another record

3. Selecting the first record

4. Scrolling down,table control shows only the 2nd and 3rd record. Now the third record is selected.

Note: Without scrolling, if you try to select two records, it will not work and only one will get selected

5. Scroll back to the top. Now two records are selected even though i defined my row selection as single in table control screen painter attributes

Currently inorder to overcome the issue, I have manually cleared the SEL value after the PAI user command module of the screen,  the SEL value in the table control structure wa_indet and internal table is cleared at the end of PAI.

Regards

Anand

Read only

0 Likes
5,225

Take a look at the demo program RSDEMO_TABLE_CONTROL. When you select 1 record in TC and try to select another record on the same screen it deselects the first one.

Hope you have generated the screen and the main program again.

Regards

Read only

0 Likes
5,225

Hi,

In the demo program, consider if you select one record and press enter or any action, the record selected will get deselected.

In my case, even if i press enter or do any action, the record should'nt get deselected. The single selection doesnt work only in case of scrolling and in all other cases single selection works fine.

Inorder to overcome the issue for now during scrolling, I cleared the SEL value after PAI user command module. In doing so, my program will also work as same as demo program u said. It will deselect the record after the actions has been completed

Read only

0 Likes
5,225

Hi

Because you don't clear the field for marker:

The output field (so marker too) can't "store" the value to be displayed, but they have to be filled every time in the PBO.

In the demo program the internal table (SDYN_SDW4) hasn't the check filed for selected rows, so if you press enter the PBO is triggered again and the mark is lost (if you check the code in PBO no values is trasnferd to MARK, the field for marker).

So I suppose you save the selected line in your internal table and transfer the value in PBO

Max

Read only

0 Likes
5,225

The idea was to show you that when you select 1 record in TC and try to select another record on the same screen it deselects the first one. The rest logic if incorporated will perform the way you want.

Read only

0 Likes
5,225

Hi,

Yes, I have saved the selected line in internal table and then transferred the value to PBO. Only in this case of transfering the values to PBO, two lines are getting selected(only during scrolling as shown in screen shots)

So to resolve the issue, currently I'am not transfering the value to PBO.

Regards

Anand

Read only

0 Likes
5,225

Hi,

Even my requirement is to select one record and it works fine. As max pointed out I transfer the value of MARK field in PBO. Even if i transfer the MARK field in PBO, It should allow to select only single record. In my case it is allowing only single record to be selected for all cases expect during scrolling scenario as I have mentioned earlier screen shots.

Regards

Anand

Read only

0 Likes
5,225

Hi

Can you post the code PBO where you transfer the data to be displyaed?

Max

Read only

0 Likes
5,225

Hi,

Im putting a sample code here

Types: Begin of ty_ic,

  ic(20),

  desc(20),

  sel(1)

End of ty_ic.

data: it_ic type table of ty_ic,

         wa_ic type ty_ic.

Note: wa_ic is the structure used in table control and wa_ic-sel is the mark field defined the table control attributes 

PBO

Loop at it_ic into wa_ic control tc_ic cursor tc_ic-current_line

Endloop.

PAI

Loop at it_ic.

Modify it_ic from wa_ic index tc_ic-current_line

Endloop

Read only

0 Likes
5,225

Ok

The "problem" is here:


Types: Begin of ty_ic,

  ic(20),

  desc(20),

  sel(1)                                 <--------------------------------

End of ty_ic.

You've ha a field for selected line and that field is used in table control definition as you've written:

"Note: wa_ic is the structure used in table control and wa_ic-sel is the mark field defined the table control attributes"


So you're using the structure WA_IC as header line of internal table IT_IC and also as input/put field of your table control (I mean the screen fields of table control are based on WA_IC).


You don't need any code in PBO to move the data from internal table to table control, because the headerline of IT_IC and field of table control are the same, infact you've implemented only the code in PAI to save the data from table control to IT_IC:



Loop at it_ic.

Modify it_ic from wa_ic index tc_ic-current_line

Endloop

t's a good solution if it needs to transfer all data to table control automatically: it doesn't need any code in PBO

but, of course, there'll be a problem when you don't need to display something, in this case you have to think a solution, I mean you have to write a code in order to avoid to display those data.

It's the case of the selected line: in your situation all selected lines keep the selection, because the code to clear IT_IC-SEL is missing: only the user can deselect a line, but if he doesn't do it, the line will remain selected after navigation.

So you make to be sure to clear all selected lines are not displayed.

You need to create a code in PAI out of the loop of table control where you clear the flag SEL, in order to do it you need to consider:

- The index of the first record displayed in table control is stored in field TC_IC-TOP_LINE

- The index of the last record displayed in table control can be calculated: the variable SY-LOOPC indicates how many rows can be displayed in table control, so the last record will be: TC_IC-TOP_LINE + SY-LOOPC.

So you need to clear the field SEL for all records not displayed, a code like this:


PROCESS PAI.

 

  LOOP AT IT_IC.

     ..................................................

     MODULE GET_LOOPC.

  ENDLOOP.

  MODULE CLEAR_SEL.


  MODULE GET_LOOPC..

      TOT_LINE_DISPLAYED = SY-LOOPC.

  ENDMODULE


  MODULE CLEAR_SEL.

* Here you need to clear the selection of the records before of TOP_LINE

       IF TC_IC-TOP_LINE > 1.

          LOOP AT IT_IC INTO WA_IC  TO TC_IC-TOP_LINE.

             CLEAR WA_IC-SEL.

             MODIFY IT_IC FROM WA_IC.

          ENDLOOP.

     ENDIF.

* Here you need to clear the selection of the records after the last one:

      LAST_INDEX = TOT_LINE_DISPLAYED + TC_IC-TOP_LINE.

     DESCRIBE TABLE IT_IC LINES SY-TABIX,

     IF SY-TABIX > LAST_INDEX.

          LOOP AT IT_IC INTO WA_IC  FROM LAST_INDEX.

             CLEAR WA_IC-SEL.

             MODIFY IT_IC FROM WA_IC.

          ENDLOOP.

     ENDIF.

  ENDMODULE.