‎2010 Sep 03 7:59 AM
HI
I have created a custom table containing 5 fields .there are two primary key fields MANDT,MIRN(custom field).
When I am trying to insert duplicate value into custom table using " INSERT YMCR296 from TABLE git_table ACCEPTING DUPLICATE KEYS." It is not updating the cuplicate values.Please Help
‎2010 Sep 03 8:05 AM
Hi,
Accepting duplicate keys is not to update the table with the duplicate entries. It simply avoids the dump for DUPREC.
If you want to add a record with the same mandt and MIRN fields, Add another field also as a primary key.
Hope it helps.
Sujay
‎2010 Sep 03 8:05 AM
Hi,
Accepting duplicate keys is not to update the table with the duplicate entries. It simply avoids the dump for DUPREC.
If you want to add a record with the same mandt and MIRN fields, Add another field also as a primary key.
Hope it helps.
Sujay
‎2010 Sep 03 8:10 AM
Hi,
See SAP Documentation on INSERT
If, for one or more of the rows to be inserted, a row with the same primary key
or the same unique secondary key already exists and the ACCEPTING DUPLICATE KEYS
addition is specified, the rows are not inserted and sy-subrc is set to 4. If, in this case,
the addition ACCEPTING DUPLICATE KEYS is not specified, no rows are inserted.
Prior to Release 6.10, this raises an exception that cannot be handled; as of Release 6.10,
this raises the exception that can be handled CX_SY_OPEN_SQL_DB.
Regards
Vinod
‎2010 Sep 03 12:05 PM
Hi,
Instead of insert use modify statement to update the database records.
Whenever you update any custom table always use modify statement instead of insert to update duplicate values.
Hope it hepls.
Karishma.
Edited by: Karishma Kadivar on Sep 3, 2010 1:05 PM
Edited by: Karishma Kadivar on Sep 3, 2010 1:14 PM
‎2010 Sep 03 10:53 PM
If you are inserting duplicate values then what is the need of primary key in your table?
‎2010 Sep 04 6:45 AM
hi,
try to use some sort of an dummy deletion indicator as the primary key by concatenating date and time which would be unique always and that would enable the insertion of duplicate entries...
with regards,
syed
‎2010 Sep 04 7:30 AM
Hi,
Add 1 more column as key say CNTR type NUMC. Increment this whenevr you add any duplicate entry. You can check duplicate entry by checking Sy-SUBRC = 4 when you use INSERT statement. For example :
INSERT ZTABLE FROM WA_ZTABLE.
IF SY-SUBRC <> 0.
SELECT MAX( CNTR ) FROM ZTABLE INTO WA_ZTABLE-CNTR
WHERE MIRN = WA_ZTABLE-MIRN.
WA_ZTABLE-CNTR = WA_ZTABLE-CNTR + 1.
INSERT ZTABLE FROM WA_ZTABLE.
ENDIF.
Thanks & Regards,
Rock.