‎2007 Dec 17 4:51 AM
Hi ,
I have an Internal table which is reading the data from different sources and inserting the data into the database table locally. I ma doing this through INSERT command but if any entry already exists in the database table this command raising a short Dump "Insert Duplicate".
Can anyone tell me the easiest way to check the data or to solve this problem.
‎2007 Dec 17 5:05 AM
hi ,
i think the way is checking sy-subrc ..if that dont work before inserting the rescord do a select query if the sy-subrc ne 0 then u can insert...
select * from table..
if sy-subrc ne 0.
insert into table.
endif
regards,
karthik
‎2007 Dec 17 4:57 AM
This is because the primary key duplicate...
the issues can be solved by checking whether the table contains the entries before insertion....
for ex:folow this steps:
check whether the entry exists in table.
if not exits:
insert
commit work.
endif...
****************************************************
insert into table.
if sy-subrc <> 0.
rollback work.
if u nedd print a error message here....
else.
commitwork.
endif.
any way its better to check whether a entry exists in table before insertion
‎2007 Dec 17 5:03 AM
correct code
This is because the primary key duplicate...
the issues can be solved by checking whether the table contains the entries before insertion....
for ex:follow this steps:
insert into table
if sy-subrc = 0.
commit work.
else.
rollback work.
if u nedd print a error message here....
endif.
endif...
any way its better to check whether the same entry exists in table before and the steps above
‎2007 Dec 17 5:04 AM
Hi,
You can use UPDATE dbtab or MODIFY dbtab commands instead of Insert command as insert command can insert a wrong value into the database table (it is going to just insert a record which you specify). So, go for either UPDATE or MODIFY commands.
Modify command and Update commands will make changes in already existing record.If it could not find that perticular record, it just inserts it.
‎2007 Dec 17 5:05 AM
hi ,
i think the way is checking sy-subrc ..if that dont work before inserting the rescord do a select query if the sy-subrc ne 0 then u can insert...
select * from table..
if sy-subrc ne 0.
insert into table.
endif
regards,
karthik
‎2007 Dec 17 5:05 AM
Hi,
The problem occured due to duplicate insertion of primary key. Check whether record already exist or not in the database table.
Ex:
Select * from dbtb where key = itab-key.
If sy-subrc <> 0.
Insert internal table data.
if sy-subrc =0.
commit work.
endif.
endif.
Otherwise you can check for the sy-subrc value after insertion.
INSERT .....into dbtable
if sy-subrc <> 0.
Message
else.
COMMIT WORK.
endif.
‎2007 Dec 17 5:19 AM
Hi Moni,
Before inserting ITAB into table check duplicate entries in iternal table and INSERT.
Loop at ITAB.
SELECT <flds> FROM <table> where field=<itab-fld>.
if sy-subrc = 4.
INSERT <into ur table>
endif.
ENDLOOP.