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 Statement Problem

Former Member
0 Likes
962

Hi,

I have two tables where i need to copy from one table to another table.

I am retrieving the data using the select statement from the first table into

internal table i_tab1.

now, i need to copy it to second table.

i did use insert statement but its not working if i have duplicate records in the second table.

can i use update statement?

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
808

Use MODIFY dbtab FROM TABLE itab.

5 REPLIES 5
Read only

former_member185931
Participant
0 Likes
808

you can use MODIFY instead of Insert, as this will update the record if it is already their in the 2nd table.

Syntax : Loop at I_TAB1.

move-corresponding i_tab1 to <2ndtable name>

modify <2ndtable name>

endloop.

or you can delete the entires from the 2nd table and use this commant

insert <2nd table name> from table <1st table name>

Message was edited by: Jagraj Dhillon

Read only

0 Likes
808

Thanks Jagraj and Srinivas. It is a fast response.

I had awarded you both the points. Thanks.

Read only

Former Member
0 Likes
809

Use MODIFY dbtab FROM TABLE itab.

Read only

Former Member
0 Likes
808

Hi

Use MODIFY statament in the same way of INSERT:

SELECT * FROM <TAB1> INTO TABLE ITAB1

WHERE .......

MODIFY <TAB2> FROM TABLE ITAB1.

Max

Read only

0 Likes
808

Hi Max,

Thanks for the answer. I will award you the points also.

Thanks.