<?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 Regarding Insert in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-insert/m-p/5427157#M1245399</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Leads,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a small issue when I am inserting data into Database Table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I am inserting the signle record into database (using work area), If insert fails..I am able to catch the exeption. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT KNA1 FROM WA_KNA1.&lt;/P&gt;&lt;P&gt; IF SY-SUBRC NE 0.&lt;/P&gt;&lt;P&gt;    RAISE  EXCEPTION_KNA1.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when I am inserting multiple records into database (using internal table), In that case I am unable to catch the exception.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;INSERT KNA1 FROM TABLE IT_KNA1.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG&gt;IF SY-SUBRC NE 0.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;    &lt;STRONG&gt;RAISE  EXCEPTION_KNA1.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ENDIF.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please give me any alternative to catch the exception in this condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sandip&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 Apr 2009 12:00:26 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-04-01T12:00:26Z</dc:date>
    <item>
      <title>Regarding Insert</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-insert/m-p/5427157#M1245399</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Leads,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a small issue when I am inserting data into Database Table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I am inserting the signle record into database (using work area), If insert fails..I am able to catch the exeption. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT KNA1 FROM WA_KNA1.&lt;/P&gt;&lt;P&gt; IF SY-SUBRC NE 0.&lt;/P&gt;&lt;P&gt;    RAISE  EXCEPTION_KNA1.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when I am inserting multiple records into database (using internal table), In that case I am unable to catch the exception.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;INSERT KNA1 FROM TABLE IT_KNA1.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG&gt;IF SY-SUBRC NE 0.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;    &lt;STRONG&gt;RAISE  EXCEPTION_KNA1.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ENDIF.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please give me any alternative to catch the exception in this condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sandip&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Apr 2009 12:00:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-insert/m-p/5427157#M1245399</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-01T12:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Insert</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-insert/m-p/5427158#M1245400</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;If you use the TABLE options in INSERT statment then if atleast one record got successfully inserted in KNA1 table then SY-SUBRC is set to 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can try this way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT  IT_KNA1 INTO WA_KNA1.
INSERT KNA1 FROM WA_KNA1.
IF SY-SUBRC NE 0.
RAISE EXCEPTION_KNA1.
ENDIF.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Apr 2009 12:05:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-insert/m-p/5427158#M1245400</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-01T12:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Insert</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-insert/m-p/5427159#M1245401</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use, addition &lt;STRONG&gt;ACCEPTING DUPLICATE KEYS&lt;/STRONG&gt; , it will avoid inserting duplicates and returns sy-subrc as 0...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pavan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Apr 2009 12:08:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-insert/m-p/5427159#M1245401</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-01T12:08:25Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Insert</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-insert/m-p/5427160#M1245402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You cannot do that if you insert using table statements, you have to do inside loop only. But it will be a performance issue. What you can do is, commit after inserting using tables and get the data from the table and cross check with you entries and populate the records which were not inserted.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Apr 2009 12:09:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-insert/m-p/5427160#M1245402</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-01T12:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Insert</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-insert/m-p/5427161#M1245403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;U have to insert all the records of internal table one by one with help of work area.&lt;/P&gt;&lt;P&gt;so use loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Apr 2009 12:24:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-insert/m-p/5427161#M1245403</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-01T12:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Insert</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-insert/m-p/5427162#M1245404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;U can incorporate this logic&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;tables: makt.

data: begin of itab occurs 0.
        INCLUDE STRUCTURE MAKT.
DATA: end of itab.
data: n type i.

itab-mandt = '800'.
itab-matnr = 'M222'.
itab-spras = 'E'.
itab-maktx = 'M2'.
itab-maktg = 'M2'.
append itab. clear itab.

itab-mandt = '800'.
itab-matnr = 'M223'.
itab-spras = 'E'.
itab-maktx = 'M3'.
itab-maktg = 'M3'.
append itab. clear itab.

itab-mandt = '800'.
itab-matnr = 'M224'.
itab-spras = 'E'.
itab-maktx = 'M4'.
itab-maktg = 'M4'.
append itab. clear itab.

itab-mandt = '800'.
itab-matnr = 'M225'.
itab-spras = 'E'.
itab-maktx = 'M5'.
itab-maktg = 'M5'.
append itab. clear itab.

DESRCIBE TABLE itab lines n.

if not itab[] is initial.
INSERT MAKT FROM TABLE ITAB.
COMMIT WORK.
ENDIF.

if n = sy-dbcnt.
  write:/ 'All records inserted'.
else.
  write:/ 'Some records missed'.
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mahesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Apr 2009 12:32:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-insert/m-p/5427162#M1245404</guid>
      <dc:creator>former_member222860</dc:creator>
      <dc:date>2009-04-01T12:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Insert</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-insert/m-p/5427163#M1245405</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;Sort on Primary keys and then use delete adjacent Duplicates on Primary keys . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or use ACCEPTING DUPLICATE KEYS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Salil...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Apr 2009 04:34:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-insert/m-p/5427163#M1245405</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-02T04:34:54Z</dc:date>
    </item>
  </channel>
</rss>

