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: 

copying a record from one table to another

Former Member
0 Kudos

hi,

I have 5 record in one internal table.

for eg.

loop at itab.

if cond. is success

copy the first record to another internal table.

endif.

endloop.

can anyone help me how to copy one record alone and insert it into another table if the condition is ok.

please help me.

Thanks,

Camila

7 REPLIES 7

Former Member
0 Kudos

hi,

try this:

loop at itab into wa where cond.

append itab2 from wa.

clear wa.

endloop.

Regards

Subramanian

Former Member
0 Kudos

Hi..,

assuming ur tables have Headerlines,

<b>loop at itab1.

if condition satisfies..

itab2 = itab1. <i>** copying that particular record into second internal table's work area..</i>

append itab2. <i>** Inserting that record into the second internal table</i>

endif.

endloop.</b>

regards,

sai ramesh

Former Member
0 Kudos

loop at itab.

if cond. is success

ITAB2 = ITAB.

< OR YOU CAN USE MOVE COMMAND ALSO IF ITAB2 AND ITAB DOES NOT HAVE THE SAME FIELDS.. THEN YOU HAVE TO WRITE

MOVE ITAB-F3 TO ITAB2-F1 LIKE THAT FOR EACH FIELD >

APPEND ITAB2.

endif.

endloop.

REGARDS

SHIBA DUTTA

Former Member
0 Kudos

Hi ....

Try this code......

loop at itab1.

if cond. is success

read table itab1 index 1 into wa. " Every time u need only first record

append wa to itab2. " copy the first record to another internal table.

endif.

endloop.

hope it helps u.

Reward points if useful......

Suresh......

Former Member
0 Kudos

hi

use the following code.

loop at itab where condition.

if sy-subrc = 0.

select single * from <database table> into corresponding fields of <itab>.

endif.

endloop.

it will work

regards ravish

<b>plz reward if helpful</b>

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

loop at itab into wa where condition.

append wa to itab1.

exit.

endloop.

Former Member
0 Kudos

Hi Joseph...

use this code...

************************************************************************

loop at itab1.

if <condition>.

move-corresponding itab1 to itab2.

append itab2.

clear itab2.

endif.

endloop.

************************************************************************

<b>Reward points if this helps,</b>

Regards,

Tejas