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: 

how to copy data fron one row to other row in same ITAB

former_member459142
Participant
0 Kudos

HI Experts

I want to cpoy data from one row to another row in same internal table itab.

thanks

1 ACCEPTED SOLUTION

praveen_hannu
Contributor
0 Kudos

take one more work area and point your concerned row and copy that row into the new work area and insert that row into the table using the sy-tabix. sy-tabix is having the row index.

6 REPLIES 6

Former Member
0 Kudos

Hi,

Use explicit work area to read table for a particular row.

read table itab into wa index <index> or using key.

now read same internal table without workarea and copy the contents from work area to itab implicit workarea and then write modify statement using index sy-tabix.

Example:

read table itab index <index> or key.

modify itab from wa index sy-tabix.

Regards,

Kumar Bandanadham

Former Member
0 Kudos

Hi ,

if suppose ur itab1 contains all the data , and you want to add a same row to that itab, then first copy all data to another table itab2 and process the itab now .


itab2[] = itab1[]. 

loop at itab1 into wa.
 
     read table itab1 into wa1 with key xyz where xyz = abc .
          if sy-subrc is initial.
             append wa1 to itab2.      " here it appends the similar row to itab2 .
          endif.
 endloop.

Now itab2 contains all the rows you wanted , i.e like duplicate entries also.

Regards,

Aby

Former Member
0 Kudos

Hi ,

if suppose ur itab1 contains all the data , and you want to add a same row to that itab, then first copy all data to another table itab2 and process the itab now .


itab2[] = itab1[]. 

loop at itab1 into wa.
 
     read table itab1 into wa1 with key xyz where xyz = abc .
          if sy-subrc is initial.
             append wa1 to itab2.      " here it appends the similar row to itab2 .
          endif.
 endloop.

Now itab2 contains all the rows you wanted , i.e like duplicate entries also.

Regards,

Aby

praveen_hannu
Contributor
0 Kudos

take one more work area and point your concerned row and copy that row into the new work area and insert that row into the table using the sy-tabix. sy-tabix is having the row index.

Former Member
0 Kudos

hi,

data:

itab,

wa1 like line of itab,

wa2 like line of itab

read table itab into wa1 index <idx>.

wa2 = wa1.

insert wa1 into itab index <idx>// the row no. where u want to copy the contents

chk sy-subrc.

hope it helps..

Regards

Mdi.Deeba

awin_prabhu
Active Contributor
0 Kudos

Try like below.

READ TABLE itab INTO wa INDEX 1. " Reading a row into workarea

MODIFY itab INDEX 2 FROM wa. " Modifying already existing row