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: 

Selected rows in module pool table control getting unselected while scrolling

Former Member
0 Kudos

Hi,

I am having a problem with my module pool program. I have a table in my module pool program. I have not created it by wizard and at this point of time I can't do that also. I have the table like below.

I now if the table has more records then we have a scroll button. In this case I have selected 2nd row and now if I scroll down to select another button this 2nd row, which is already selected is getting unselected.

How can I make this selected when scroll also.

Thanks & Regards,

Supratik

1 ACCEPTED SOLUTION

Former Member
0 Kudos

To understand the solution, you need to understand what is happening when you scroll (up or down).  When you mark a specific row in your table (as shown in the image in your original question) you are setting the selection column with an 'X' for that particular row.  When you scroll up or down at that point, you trigger PAI.  You continue to trigger PAI if you keep scrolling.  The table control that holds the data for your table contains a special field

In order to hold on to the marked fields, you need to transfer the selected row information from your table control to your internal table.  What your user sees when they run your program is just what's displayed in the viewable window area.  If your table is large, the user will need to scroll (up or down) through several pages in order to see all the contents.  So, if your table control only displays 9 rows at a time, and your internal table has 100 rows, the table control will have to scroll several times before the user will be able to review all the rows of information in the table.

Each time the user scrolls to a new section of the table, they are triggering PAI.  So, the first thing you need to do is to store whatever the user has selected in the viewable area when they trigger the PAI event.  Then, in the PBO, you ensure that you extract the saved information from gt_itab so the user sees the selected rows from a previous view (if the user selected one or more rows for that viewable area).  The following is an example of the code that might accomplish this:

The blurred areas might be other modules you call in PBO or PAI.  The most important section is not blurred (LOOP).  You see that there is a LOOP in the PBO and another one in the PAI.  These must be implemented like this to work properly.

gs_itab (in the PBO event) should be declared in the TOP INCLUDE and have the same structure as a single row of gt_itab.

In the PAI event, you see that we're calling the save_selected_rows module.  The following might be the code you would see in that module:

This ensures that we store the viewable, selected row information in our table (gt_itab) at PAI, but before we trigger PBO.  When we get around to triggering PBO, we want to be sure that we display the row as being selected if we've already been to that viewable area before, and the user selected one of those viewable rows before.  We do this in the PBO event by calling the module update_selected_rows.  The following is the code we might expect to see there:

This code ensures that we post gs_itab-check information to our screen control value for "CHECK".  This sets the row marker for that viewable area.  When the user finally sees the displayed, viewable area of the table control, they will see the rows that have been previously marked.

I hope this has been helpful.

4 REPLIES 4

Former Member
0 Kudos

Hi

Your internal table should have a field (flag) for mark: this field has to be filled in the row is selected, in this way your module pool can store the selected rows while scrolling.

If you don't use a field for selection, the selection will be lost while scrolling

Max

0 Kudos

Hi Max,

Yes, I do have a field called check in my internal table as "check". Actually this field is getting cleared when I hit enter or scroll. How can I keep this value.

Regards,

Supratik

0 Kudos

Hi

You need to manage it in PAI, here you should have a module where you move the data from screen to your internal table, in particular the field for selection.

Something like this:

PROCESS AFTER INPUT.

   LOOP WITH CONTROL <table control>.

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

     FIELD CHECK MODULE SET_SELECTED_LINE.

     MODULE MODIFY_ITAB.

   ENDLOOP.


MODULE SET_SELECTED_LINE.

    ITAB-CHECK = CHECK.

ENDMODULE.


MODULE MODIFY_ITAB.

   MODIFY ITAB INDEX <TABLE CONTROL>-CURRENT_LINE.

ENDMODULE.


Max

Former Member
0 Kudos

To understand the solution, you need to understand what is happening when you scroll (up or down).  When you mark a specific row in your table (as shown in the image in your original question) you are setting the selection column with an 'X' for that particular row.  When you scroll up or down at that point, you trigger PAI.  You continue to trigger PAI if you keep scrolling.  The table control that holds the data for your table contains a special field

In order to hold on to the marked fields, you need to transfer the selected row information from your table control to your internal table.  What your user sees when they run your program is just what's displayed in the viewable window area.  If your table is large, the user will need to scroll (up or down) through several pages in order to see all the contents.  So, if your table control only displays 9 rows at a time, and your internal table has 100 rows, the table control will have to scroll several times before the user will be able to review all the rows of information in the table.

Each time the user scrolls to a new section of the table, they are triggering PAI.  So, the first thing you need to do is to store whatever the user has selected in the viewable area when they trigger the PAI event.  Then, in the PBO, you ensure that you extract the saved information from gt_itab so the user sees the selected rows from a previous view (if the user selected one or more rows for that viewable area).  The following is an example of the code that might accomplish this:

The blurred areas might be other modules you call in PBO or PAI.  The most important section is not blurred (LOOP).  You see that there is a LOOP in the PBO and another one in the PAI.  These must be implemented like this to work properly.

gs_itab (in the PBO event) should be declared in the TOP INCLUDE and have the same structure as a single row of gt_itab.

In the PAI event, you see that we're calling the save_selected_rows module.  The following might be the code you would see in that module:

This ensures that we store the viewable, selected row information in our table (gt_itab) at PAI, but before we trigger PBO.  When we get around to triggering PBO, we want to be sure that we display the row as being selected if we've already been to that viewable area before, and the user selected one of those viewable rows before.  We do this in the PBO event by calling the module update_selected_rows.  The following is the code we might expect to see there:

This code ensures that we post gs_itab-check information to our screen control value for "CHECK".  This sets the row marker for that viewable area.  When the user finally sees the displayed, viewable area of the table control, they will see the rows that have been previously marked.

I hope this has been helpful.