11-13-2007 6:41 AM
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.
11-13-2007 6:43 AM
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.
11-13-2007 6:45 AM
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
11-13-2007 6:56 AM
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
11-13-2007 8:13 AM
Hi Guru,
It's strange that when I run the script again ,no records were inserted, only the ones inserted earlier. What cause this?
11-13-2007 8:23 AM
use this....
modify dbtable from table itab.
The duplicate records will be get updated....
New records will be inserted...
11-13-2007 7:03 AM
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.