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: 

adding/removing rows in TABLEVIEW

Former Member
0 Kudos
187

Hi. I've got a TABLEVIEW in one of my subscreens. But when load itab into that tableview with 'LOOP AT...' tableview appears but I can't add rows to it. I can't delete existing rows too. What should I add to my programm to have possibility of adding/removing rows from my tablewiev? Greetings. P.

1 ACCEPTED SOLUTION

krishnendu_laha
Active Contributor
0 Kudos
48

Hi Friend,

To add/delete rows in your table view.

You have to add/delete rows from internal table fro where you are displaying values.

You have to write code in PAI..

In LOOP ... ENDLOOP check the OK_CODE if it is ADD (for eg.) you have to add a blank row to internal table by just passing a blank work area.

And if it is DELETE (for eg.) delete the row of that index (TABLEVIEW-CURRENT_LINE)...

for these two excersies you have to readjust lines of tableview...after taking number of lines from internal table (DESCRIBE TABLE INT_EX LINES WS_LINES

TABLEVIEW-LINES = WS_LINES) write this piece of code in Intialization.

Hope it will solve the problem.

Regards

Krishnendu

3 REPLIES 3

former_member589029
Active Contributor
0 Kudos
48

Just add a few empty lines to your internal table and set the number of lines for the table control accordingly.

e.g.

itab has 5 lines with data

append 3 empty lines to itab

Set TABLECONTROL-LINES to 8 where TABLECONTROL is the name of your table control.

Hope that helps,

Michael

krishnendu_laha
Active Contributor
0 Kudos
49

Hi Friend,

To add/delete rows in your table view.

You have to add/delete rows from internal table fro where you are displaying values.

You have to write code in PAI..

In LOOP ... ENDLOOP check the OK_CODE if it is ADD (for eg.) you have to add a blank row to internal table by just passing a blank work area.

And if it is DELETE (for eg.) delete the row of that index (TABLEVIEW-CURRENT_LINE)...

for these two excersies you have to readjust lines of tableview...after taking number of lines from internal table (DESCRIBE TABLE INT_EX LINES WS_LINES

TABLEVIEW-LINES = WS_LINES) write this piece of code in Intialization.

Hope it will solve the problem.

Regards

Krishnendu

Former Member
0 Kudos
48

You can place buttons for add and subtract..

when clicking add:

describe table <itab> lines < line>.

<tblctrl>-lines = line + 1.

when clicking subtract:

dealete <itba> index <index of the row>.

describe table <itab> lines < line>.

<tblctrl>-lines = line .

itab : internal table used for populating data.

line : is a variable type i.

tblctrl : is the anme of table control.

regards.