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

Single selection in table control

Former Member
0 Likes
1,479

hii all..

I am stuck at a very unique problem. i have created a table control to display some data. from that control user can select only a single row. So for that i have set the table control attribute single row selection. Now the problem is suppose i have 50 rows in my internal table that is showing in table control. In the table control 25 rows are displayed at a time. When user presses Page down the next 25 rows are displayed.

Now when table control is showing first set of 25 rows, a user is able to select only a single row according to the attribute that i have set. But when a user selects any row in the first 25 rows and presses Page down and then selects another row in the next set of 25 rows, both the previous selection and the current selection are retained which i didnt wanted.

How can i solve this problem.... really got stuck

points guranteed!!

7 REPLIES 7
Read only

Former Member
0 Likes
1,030

Hi,

Select the records that were selected in the table control into an internal table.

then describe that table for the number of records.

if count is more than one display error message saying that only one record has to be selected.

reward if useful

regards,

Anji

Read only

0 Likes
1,030

Use the below code...it will work

* Read index of selected rows
      CALL METHOD g_alvgrid->get_selected_rows
        IMPORTING
          et_index_rows = gi_index_rows.

DESCRIBE TABLE gi_index_rows LINES l_lines.
      IF l_lines > 1.
  message 'Select only 1 row' type I.
   endif.

Read only

former_member196299
Active Contributor
0 Likes
1,030

hi Baldeep ,

I think there is some problem with the logic. You are able to select only one row when u see 25 rows in ur 1st page n again 1 select in ur 2nd page .

Why dont you use a condition for selecting only one row in the internal table. loop at the TC internal table and use the condition as wehn SEL = "X". and as soon as u capture the 1st selected row exit from the loop . This way you can capture only one row out of the 2 rows from the Itab .

I hope this works !

Reward if helpful,

Thanks

Ranjita

Read only

Former Member
0 Likes
1,030

Hi Baldeep,

<b>

Fewdays I faced the same problem....</b>

Baldeep Your requirement is not possible just by set the table control attribute single row selection.You have to write some logic to accomplish this like putting one more like REFRESH write some code to refresh the table control.....i.e., already selected lines to be deselected.....

<b>Hope this is helpful for you.

Reward all helpful answers.</b>

Regards,

V.Raghavender.

Read only

0 Likes
1,030

Hi,

In every PAI count the no. of selected records and in every PBO if the count is greater than one, then give the information message and unselect all those selected rows.

<u>Example</u>:

CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.

DATA: count type i.

MODULE status_0100 OUTPUT.

SET PF-STATUS 'SCREEN_100'.

if count > 1.

count = 0.

message 'You can select only a single Record' type 'I' .

loop at itab into wa.

wa-mark = ' '.

modify itab from wa.

endloop.

endif.

ENDMODULE.

MODULE count_selected_rows INPUT.

loop at itab into wa.

if wa-mark = 'X'.

count = count + 1.

endif.

endloop.

ENDMODULE. " count_selected_rows INPUT\

<b>Screen FlowLogic</b>

PROCESS BEFORE OUTPUT.

MODULE STATUS_0100.

LOOP AT ITAB INTO DEMO_CONN WITH CONTROL FLIGHTS.

ENDLOOP.

PROCESS AFTER INPUT.

MODULE CANCEL AT EXIT-COMMAND.

LOOP AT ITAB.

module read_table_control.

ENDLOOP.

module count_selected_rows.

module user_command_0100.

<b>Reward if useful,</b>Regards,

Sudheer

Read only

0 Likes
1,030

Hi,

U need to <b>award points for useful answers</b> and u have to mention it as solved if ur question is solved. Dont forget.

Regards,

Sudheer

Read only

former_member491305
Active Contributor
0 Likes
1,030

Hi,

There is no need to put the messages at all like 'U have selected more than one page' and also there is no need to go for PBO for validating the sel field.

Simply put the code like this.

PROCESS AFTER INPUT.

LOOP AT it_ekko.

FIELD x_ekko-sel MODULE tc_mark ON REQUEST.

Endloop.

MODULE tc_mark INPUT.

DATA: g_tc_wa2 LIKE LINE OF it_ekko.

IF tc-line_sel_mode = 1

AND x_ekko-sel = 'X'.

LOOP AT it_ekko INTO g_tc_wa2

WHERE sel = 'X'.

g_tc_wa2-sel = ''.

MODIFY it_ekko

FROM g_tc_wa2

TRANSPORTING sel.

ENDLOOP.

ENDIF.

MODIFY it_ekko

FROM x_ekko

INDEX tc-current_line

TRANSPORTING sel.

ENDMODULE. "TC_MARK INPUT