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

Determining selected lines in screen table control

Former Member
0 Likes
1,818

Hi,

I have developed a screen in Screen Painter (SE51) with two table controls. I am using two internal tables, ITAB1 and ITAB2 to fill these tables. Using the code below the screen tables get filled with the data in the internal tables without any problem.

Now I need that the rows displayed on the screen for ITAB1 should be selectable and upon clicking a button the selected rows should be displayed in ITAB2 on screen. In Screen Painter for control SCR_ITAB1 I have defined both line and column selection attributes as 'Multiple' and checked the w / SelColumn checkbox with name SELCOL.

How do I determine which rows have been selected? Example code would be very helpful. Thanks.

Regards

ABAP Program Code:

CONTROLS: SCR_ITAB1 TYPE TABLEVIEW USING SCREEN '9501'.

CONTROLS: SCR_ITAB2 TYPE TABLEVIEW USING SCREEN '9501'.

MODULE FILL_ITAB1 OUTPUT.

DESCRIBE TABLE ITAB LINES SCR_ITAB1-LINES.

ENDMODULE.

MODULE FILL_ITAB2 OUTPUT.

DESCRIBE TABLE ITAB2 LINES SCR_ITAB2-LINES.

ENDMODULE.

PBO in Screen Painter:

PROCESS BEFORE OUTPUT.

MODULE TESTTAB_CHANGE_TC_ATTR.

LOOP AT ITAB1

INTO ITAB1

WITH CONTROL SCR_ITAB1

CURSOR SCR_ITAB1-CURRENT_LINE.

ENDLOOP.

MODULE DISPLAY_MYTAB_9501.

LOOP AT ITAB2

INTO ITAB2

WITH CONTROL SCR_ITAB2

CURSOR SCR_ITAB2-CURRENT_LINE.

ENDLOOP.

PAI in Screen Painter:

PROCESS AFTER INPUT.

LOOP AT ITAB1.

ENDLOOP.

LOOP AT ITAB2.

ENDLOOP.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,041

Hi,

In PAI,

loop at itab1.

describe table itab1 lines tc1-lines.

if tc1-current_line > tc1-lines.

append itab1.

else.

modify itab1 index tc1-current_line.

endif.

endloop.

then your other coding follows.

in PAI

module enter.

in the program

module enter

if you want multilple rows to be selected you need to loop the itab1 else single read statement will do the job

refresh itab2.

read table itab1 where selcol = 'X'

move itab1 to itab1.

append itab2.

endlmodule.

Hope this will work for you.

Regards

Ramchander Rao.K

Hi,

I have developed a screen in Screen Painter (SE51) with two table controls. I am using two internal tables, ITAB1 and ITAB2 to fill these tables. Using the code below the screen tables get filled with the data in the internal tables without any problem.

Now I need that the rows displayed on the screen for ITAB1 should be selectable and upon clicking a button the selected rows should be displayed in ITAB2 on screen. In Screen Painter for control SCR_ITAB1 I have defined both line and column selection attributes as 'Multiple' and checked the w / SelColumn checkbox with name SELCOL.

How do I determine which rows have been selected? Example code would be very helpful. Thanks.

Regards

ABAP Program Code:

CONTROLS: SCR_ITAB1 TYPE TABLEVIEW USING SCREEN '9501'.

CONTROLS: SCR_ITAB2 TYPE TABLEVIEW USING SCREEN '9501'.

MODULE FILL_ITAB1 OUTPUT.

DESCRIBE TABLE ITAB LINES SCR_ITAB1-LINES.

ENDMODULE.

MODULE FILL_ITAB2 OUTPUT.

DESCRIBE TABLE ITAB2 LINES SCR_ITAB2-LINES.

ENDMODULE.

PBO in Screen Painter:

PROCESS BEFORE OUTPUT.

MODULE TESTTAB_CHANGE_TC_ATTR.

LOOP AT ITAB1

INTO ITAB1

WITH CONTROL SCR_ITAB1

CURSOR SCR_ITAB1-CURRENT_LINE.

ENDLOOP.

MODULE DISPLAY_MYTAB_9501.

LOOP AT ITAB2

INTO ITAB2

WITH CONTROL SCR_ITAB2

CURSOR SCR_ITAB2-CURRENT_LINE.

ENDLOOP.

PAI in Screen Painter:

PROCESS AFTER INPUT.

LOOP AT ITAB1.

ENDLOOP.

LOOP AT ITAB2.

ENDLOOP.

2 REPLIES 2
Read only

Former Member
0 Likes
1,041

when you have checked the w/Selcolumn you will give a name for it in the textbox.(ex: s_row)take that and in your internal table add that to your column. ITAB1. if a row is selected this column will be filled with 'X'.you can loop through the internal table and get the selected orws.

in PAI. 
LOOP AT itab1. 
IF itab1-s_row = 'X'. 
move itab1-current_line to i_itab2-row.
ENDIF.
ENDLOOP.

Read only

Former Member
0 Likes
1,042

Hi,

In PAI,

loop at itab1.

describe table itab1 lines tc1-lines.

if tc1-current_line > tc1-lines.

append itab1.

else.

modify itab1 index tc1-current_line.

endif.

endloop.

then your other coding follows.

in PAI

module enter.

in the program

module enter

if you want multilple rows to be selected you need to loop the itab1 else single read statement will do the job

refresh itab2.

read table itab1 where selcol = 'X'

move itab1 to itab1.

append itab2.

endlmodule.

Hope this will work for you.

Regards

Ramchander Rao.K