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: 

Duplicate database records.

Former Member
0 Kudos

Hi Gurus,

I am trying to insert into a db table from an internal tbl. And the result return error as shown below:

The ABAP/4 Open SQL array insert results in duplicate database records.

How do I solve this?

Thank you in advanced.

6 REPLIES 6

Former Member
0 Kudos

Hi..

You cannot enter duplicate records into Data base tables..

here duplicate in the sense you are trying enter one or more records, for which there is a similar record in the database exists with the same primary key.

Only thing you can do is go for UPDATE statement instead of INSERT.

Former Member
0 Kudos

Hi, before inserting record, make sure the record already exit in the db table. if so, give error message

use MODIFY statement for inserting or updating

Suku

Former Member
0 Kudos

Hi

Please use the addition <b>ACCEPTING DUPLICATE KEYS</b> along with INSERT.

When this addition is used no short dump is generated instead sy-subrc is set to 4. You may check this sy-subrc value and proceed with your logic...

Regards,

Arun

0 Kudos

Hi Guru,

It's strange that when I run the script again ,no records were inserted, only the ones inserted earlier. What cause this?

0 Kudos

use this....

modify dbtable from table itab.

The duplicate records will be get updated....

New records will be inserted...

mahaboob_pathan
Contributor
0 Kudos

Hi,

The following code can be used as a template to produce an ABAP which updates a particular database

table field.

&----


*& Report ZUPDATE_PRPS *

*& *

&----


*& *

*& Quick report to Update PRPS-FAKKZ database field *

&----


Report ZUPDATE_PRPS.

tables: prps.

parameter: p_wbs like prps-pspnr,

p_value like prps-fakkz default 'X'.

data: wa_fakkz type prps-fakkz.

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

*START-OF_SELECTION

start-of-selection.

call function 'CONVERSION_EXIT_ABPSP_INPUT'

exporting

input = p_wbs

importing

output = p_wbs

exceptions

not_found = 1

others = 2.

select single fakkz

into wa_fakkz

from prps

where pspnr eq p_wbs.

if sy-subrc eq 0.

update prps set fakkz = p_value where PSPNR eq p_wbs.

if p_value is initial.

message i999(za) with 'Billing element field has been unchecked'.

else.

message i999(za) with 'Billing element field has been checked'.

endif.

else.

message i999(za) with 'WBS element not found'.

endif.