‎2010 Aug 20 11:29 AM
Hi ,
i am updating a ztable ZMM_PRIMO_DUPERR from itab I_DPAIR .
in my ztable there is a field PROCESSING_DATE which is the only primary key .
and in my itab i have 2 records on the same processing date . i mean for a particular key, Duplicate record exists in I_DPAIR .
i want to update both records into the ztable.so i write the below code,but its not working, Its only inserting the first record ?
how this below syntax works ??
INSERT ZMM_PRIMO_DUPERR FROM TABLE I_DPAIR ACCEPTING DUPLICATE KEYS
please share your thoughts ..
‎2010 Aug 20 11:37 AM
Hi,
As you said its not inserting 2 similar records.
It would never insert 2 records with same primary key.
Otherwise what's the use of primary key.
‎2010 Aug 20 11:42 AM
yes you are true ...
But wht is the use of ACCEPTING DUPLIACTE KEYS ??
‎2010 Aug 20 11:42 AM
‎2010 Aug 20 11:51 AM
Hi Sagar,
Using "Accepting duplicate keys" will only set the sy-subrc = 4 when you try to insert duplicate records into the DB table from an internal table so that we can handle this exception.
Regards,
‎2010 Aug 20 11:52 AM
HI Nagraj,
so you mean , the syntax is only to avoid sortdump , but it wont add any dupliacte records .?
‎2010 Aug 20 11:55 AM
Yes thats correct. In this case all the unique records will be inserted and the duplicates will be rejected.
‎2010 Aug 20 12:07 PM
Hi,
ACCEPTING DUBLICATE ENTRIES is to avoid the dump.It wont add duplicate entries in the database table.If you don't use the keyword ACCEPTING DUBLICATE ENTRIES, you will get a dump.
‎2010 Aug 20 12:07 PM
In case of doubt, read the Abap documentation first [FROM TABLE itab [ACCEPTING DUPLICATE KEYS]|http://help.sap.com/abapdocu_70/en/ABAPINSERT_SOURCE.htm#&ABAP_ALTERNATIVE_2@2@] or via F1, it is cleary written.
(SQL basic : A Primary Key Constraint is an extension of [Unique Key|http://en.wikipedia.org/wiki/Primary_key] Constraint with the addition of a Not Null Constraint)
Regards,
Raymond
‎2010 Aug 20 12:10 PM
Then what is the exact purpose of primary key ?
you have to create one more primary key which together uniquley identifies a record.
‎2010 Aug 20 12:29 PM
Hi,
Just CHeck this Documentation from SAP :
... ACCEPTING DUPLICATE KEYS
Effect
If a line cannot be inserted, the system does not
terminate with a runtime error but only sets the return value SY-SUBRC to 4. All other lines are inserted after the command is executed
i.e. so as to just avoid the dump we can use this syntax.
But we cannot insert duplicate records in a table.
Any ways if you have to insert duplicate you have to change your primary key's and table design.
‎2010 Aug 23 5:43 AM
HI ,
Yes now i am clear.. Thanks to all for their valuable tips ..
I have to redesign the DB table.
Thanks to all