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

Insert row in ALV grid

Former Member
0 Likes
823

hi experts!!

i am working on ALv using OO.I have to insert the datas in the grid for which i have a Insert Button.

when i insert the row i am geetting the values in the ITAB from which i am modifying my DB table. but when i insert anew row its getting modifed in the existing top row insted of ineserting a new row.

plz guide me wats wrong with teh same.

plzzz replye me.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
684

Hi,

First ask the user to select the row and click on insert button.

Ask option whether he wants to insert before or after current row.

Then you can find the index of the current selected row. based up on the option he selects, insert the row into the GRID.

l_index = sy-index +1 (or -1).

INSERT

INTO it_tab INDEX l_index

Reward points if useful.

Regards,

Niyaz

5 REPLIES 5
Read only

Former Member
0 Likes
685

Hi,

First ask the user to select the row and click on insert button.

Ask option whether he wants to insert before or after current row.

Then you can find the index of the current selected row. based up on the option he selects, insert the row into the GRID.

l_index = sy-index +1 (or -1).

INSERT

INTO it_tab INDEX l_index

Reward points if useful.

Regards,

Niyaz

Read only

0 Likes
684

hii thankx..

i have used Get_selected_row and after inserting a row and preseing 'save button also its not updating the DB table as new row but updating in same row..

but in ITAb i used index like:

l_index = l_row-index.

read table pt_102[] into lt_102 index l_index .

modify y4arc_res_period from lt_102 .

please help me..

Read only

Former Member
0 Likes
684

how u r inserting into ITAB.

Try Appending to ITAB and then SORT...

It will work.

Read only

0 Likes
684

hii thankx..

i have used Get_selected_row and after inserting a row and preseing 'save button also its not updating the DB table as new row but updating in same row..

but in ITAb i used index like:

l_index = l_row-index.

read table pt_102[] into lt_102 index l_index .

modify y4arc_res_period from lt_102 .

please help me..

Read only

Former Member
0 Likes
684

Hi,

Use the following.

data: itab1 like itab(ur internal table used in prog) occurs 0 with header line.

data: l_index like sy-index.

read current line.

l_index = line + 1.

OR

l_index = line - 1.

INSERT

INTO itab1 INDEX l_index.

Reward points if helpful

Srimanta