<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic INSERT from itab ACCEPTING DUPLICATE KEYS in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-from-itab-accepting-duplicate-keys/m-p/1791006#M340318</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was wanting to know the behaviour of the ' INSERT from itab ACCEPTING DUPLICATE KEYS '.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My understanding is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My doubt is : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way where in i can insert the rows which are not existing in the database and then capture sy-subrc for further processing. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or is there a better way of approching.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ramesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Jan 2007 17:34:20 GMT</pubDate>
    <dc:creator>ramesh_kajuru</dc:creator>
    <dc:date>2007-01-03T17:34:20Z</dc:date>
    <item>
      <title>INSERT from itab ACCEPTING DUPLICATE KEYS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-from-itab-accepting-duplicate-keys/m-p/1791006#M340318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was wanting to know the behaviour of the ' INSERT from itab ACCEPTING DUPLICATE KEYS '.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My understanding is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My doubt is : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way where in i can insert the rows which are not existing in the database and then capture sy-subrc for further processing. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or is there a better way of approching.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ramesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jan 2007 17:34:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-from-itab-accepting-duplicate-keys/m-p/1791006#M340318</guid>
      <dc:creator>ramesh_kajuru</dc:creator>
      <dc:date>2007-01-03T17:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: INSERT from itab ACCEPTING DUPLICATE KEYS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-from-itab-accepting-duplicate-keys/m-p/1791007#M340319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi in ur case modify statement solves the issue&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;modify statement works for inserting a record into the Database table if it doesnt exist and modifying an existing record if it already exists&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;modify ztable from itab&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the syntax followed, reward points if found helpful&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jan 2007 17:42:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-from-itab-accepting-duplicate-keys/m-p/1791007#M340319</guid>
      <dc:creator>rahulkavuri</dc:creator>
      <dc:date>2007-01-03T17:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: INSERT from itab ACCEPTING DUPLICATE KEYS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-from-itab-accepting-duplicate-keys/m-p/1791008#M340320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ramesh, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please specify your exact requirement. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) If you want to insert rows from internal table, 'ACCEPTING DUPLICATE KEYS' will prevent the program termination. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT ZTEST_TABLE FROM TABLE LT_TABLE .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In case a duplicate row exist, you will get dump. So anytime you want to insert from internal table, you need to insert 'Accepting duplicate keys'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) If you are allowed to change existing rows, then you can use 'MODIFY' statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) If your requirement is to identify the individual rows that already exist (for reporting purpose), please use a SELECT statement with 'FOR ALL ENTRIES'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If ZTABLE is your table with primary key k1. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT K1 INTO TABLE ITAB2 &lt;/P&gt;&lt;P&gt;FROM ZTABLE WHERE K1 = itab-k1 for all entries in itab. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ITAB2 will now contain all the entries that already exist in ITAB2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Other option would be to loop at your original table and insert row by row, doing sy-subrc check to find duplicate rows. &lt;/P&gt;&lt;P&gt;LOOP AT ITAB1. &lt;/P&gt;&lt;P&gt;  INSERT ZTABLE FROM ITAB1. &lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jan 2007 19:36:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-from-itab-accepting-duplicate-keys/m-p/1791008#M340320</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-03T19:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: INSERT from itab ACCEPTING DUPLICATE KEYS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-from-itab-accepting-duplicate-keys/m-p/1791009#M340321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Purpose of ACCEPTING DUPLICATE KEYS is as follows :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mass insert: Inserts all lines of table itab in a single operation. The lines of itab must satisfy the same condition as the work area wa in variant 1. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After the statement has been executed, the system field SY-DBCNT contains the number of lines inserted. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the system cannot insert a line, the program does not terminate with a runtime error. Instead, SY-SUBRC is set to 4. All lines of the internal table after the one that could not be inserted are still inserted into the database table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax &lt;/P&gt;&lt;P&gt;INSERT dbtab [CLIENT SPECIFIED] FROM TABLE itab. or INSERT (dbtabname) [CLIENT SPECIFIED] FROM TABLE itab. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Addition: ... ACCEPTING DUPLICATE KEYS &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Naresh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jan 2007 19:42:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-from-itab-accepting-duplicate-keys/m-p/1791009#M340321</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-03T19:42:27Z</dc:date>
    </item>
  </channel>
</rss>

