<?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 Records in Database table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-records-in-database-table/m-p/3723072#M896119</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 am trying to insert values in table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at it_header.&lt;/P&gt;&lt;P&gt; INSERT YTAB from table it_header accepting duplicate keys.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, the records are not getting inserted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pl guide.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Netra&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 28 Apr 2008 12:43:21 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-04-28T12:43:21Z</dc:date>
    <item>
      <title>Insert Records in Database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-records-in-database-table/m-p/3723072#M896119</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 am trying to insert values in table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at it_header.&lt;/P&gt;&lt;P&gt; INSERT YTAB from table it_header accepting duplicate keys.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, the records are not getting inserted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pl guide.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Netra&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Apr 2008 12:43:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-records-in-database-table/m-p/3723072#M896119</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-28T12:43:21Z</dc:date>
    </item>
    <item>
      <title>Re: Insert Records in Database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-records-in-database-table/m-p/3723073#M896120</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;&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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;madhu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Apr 2008 12:46:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-records-in-database-table/m-p/3723073#M896120</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-28T12:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: Insert Records in Database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-records-in-database-table/m-p/3723074#M896121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi check this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you specify an internal table itab, several rows are created from its contents for insertion into the database table. A row for insertion into the database table is take from each row of the internal table, using the same rules as for an individual work area wa. The row type of the internal table must meet the prerequisites for use in Open SQL statements. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If a row with the same primary key or the same unique secondary key does not already exist in the database table for any of the rows to be inserted, all rows are inserted and sy-subrc is set to 0. If the internal table is empty, sy-subrc is also set to 0. The system field sy-dbcnt is always set to the number of rows actually inserted. &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. 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. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;venkat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Apr 2008 12:48:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-records-in-database-table/m-p/3723074#M896121</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-28T12:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: Insert Records in Database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-records-in-database-table/m-p/3723075#M896122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Additionally, you're code will try to insert the table multiple times&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of this&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
loop at it_header.
  INSERT YTAB from table it_header accepting duplicate keys.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you only need this&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  INSERT YTAB from table it_header accepting duplicate keys.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Apr 2008 12:53:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-records-in-database-table/m-p/3723075#M896122</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-28T12:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: Insert Records in Database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-records-in-database-table/m-p/3723076#M896123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are inserting the it_header (internal table) records to your YTAB (DB table)....then follow the code...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT YTAB from table it_header accepting duplicate keys.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No need for Loop...endloop.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are inserting the it_header (internal table) records to your YTAB (internal table)....then follow the code...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT lines of it_header INTO TABLE ytab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please refer this link:&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw70/helpdata/EN/fc/eb3a6d358411d1829f0000e829fbfe/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw70/helpdata/EN/fc/eb3a6d358411d1829f0000e829fbfe/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Apr 2008 12:56:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-records-in-database-table/m-p/3723076#M896123</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-28T12:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: Insert Records in Database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-records-in-database-table/m-p/3723077#M896124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Insert YTAB from table it_header ACCEPTING DUPLICATE KEYS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Apr 2008 12:56:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-records-in-database-table/m-p/3723077#M896124</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-28T12:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: Insert Records in Database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-records-in-database-table/m-p/3723078#M896125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;To insert several lines into a database table, use the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT &amp;lt;target&amp;gt; FROM TABLE &amp;lt;itab&amp;gt; [ACCEPTING DUPLICATE KEYS].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This writes all lines of the internal table &amp;lt;itab&amp;gt; to the database table in one single operation. The&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;same rules apply to the line type of &amp;lt;itab&amp;gt; as to the work area &amp;lt;wa&amp;gt; described above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the system is able to insert all of the lines from the internal table, SY-SUBRC is set to 0. If one&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or more lines cannot be inserted because the database already contains a line with the same&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;primary key, a runtime error occurs. You can prevent the runtime error occurring by using the&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;addition ACCEPTING DUPLICATE KEYS. In this case, the lines that would otherwise cause&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;runtime errors are discarded, and SY-SUBRC is set to 4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The system field SY-DBCNT contains the number of lines inserted into the database table,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regardless of the value in SY-SUBRC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Whenever you want to insert more than one line into a database table, it is more efficient to work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with an internal table than to insert the lines one by one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Examples&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Adding single lines&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TABLES SPFLI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA WA TYPE SPFLI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WA-CARRID = 'LH'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WA-CITYFROM = 'WASHINGTON'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT INTO SPFLI VALUES WA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WA-CARRID = 'UA'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WA-CITYFROM = 'LONDON'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT SPFLI FROM WA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SPFLI-CARRID = 'LH'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SPFLI-CITYFROM = 'BERLIN'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT SPFLI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This program inserts a single line into the database table SPFLI using each of the&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;three possible variants of the INSERT statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT SPFLI&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the last line, you could also use the longer forms&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT SPFLI FROM SPFLI&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT INTO SPFLI VALUES SPFLI&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The name SPFLI is therefore not unique.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: ITAB TYPE HASHED TABLE OF SPFLI&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WITH UNIQUE KEY CARRID CONNID,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WA LIKE LINE OF ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WA-CARRID = 'UA'. WA-CONNID = '0011'. WA-CITYFROM = ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT WA INTO TABLE ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WA-CARRID = 'LH'. WA-CONNID = '1245'. WA-CITYFROM = ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT WA INTO TABLE ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WA-CARRID = 'AA'. WA-CONNID = '4574'. WA-CITYFROM = ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT WA INTO TABLE ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT SPFLI FROM TABLE ITAB ACCEPTING DUPLICATE KEYS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ELSEIF SY-SUBRC = 4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This example fills a hashed table ITAB and inserts its contents into the database&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;table SPFLI. The program examines the contents of SY-SUBRC to see if the&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;operation was successful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Apr 2008 12:58:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-records-in-database-table/m-p/3723078#M896125</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-28T12:58:05Z</dc:date>
    </item>
  </channel>
</rss>

