<?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 Re: Handle INSERT exception in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/handle-insert-exception/m-p/3408760#M818666</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;you can make to popup a message relavently.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
IF &amp;lt;variable&amp;gt; is NOT INITIAL.
    INSERT &amp;lt;table&amp;gt; FROM TABLE &amp;lt;itab&amp;gt;.
    IF sy-subrc = 0.    "data inserted successfully
       DESCRIBE TABLE...
    ELSE.               "data not inserted
       MESSAGE 'table insertion error' TYPE 'I'.
    ENDIF.
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;lt;REMOVED BY MODERATOR&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;teja&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Alvaro Tejada Galindo on Feb 21, 2008 4:33 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 21 Feb 2008 10:07:40 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-02-21T10:07:40Z</dc:date>
    <item>
      <title>Handle INSERT exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/handle-insert-exception/m-p/3408759#M818665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i need to handle exception for below code. PLS HELP ME. &lt;/P&gt;&lt;P&gt;when i trying for error records it ll got to dump&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF itab_zdfkkwoh IS NOT INITIAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        INSERT zdfkkwoh FROM  TABLE itab_zdfkkwoh.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;        DESCRIBE TABLE itab_zdfkkwoh LINES  countb.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      ELSE.&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;*???????&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Alvaro Tejada Galindo on Feb 21, 2008 4:33 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2008 09:27:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/handle-insert-exception/m-p/3408759#M818665</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-21T09:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: Handle INSERT exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/handle-insert-exception/m-p/3408760#M818666</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;you can make to popup a message relavently.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
IF &amp;lt;variable&amp;gt; is NOT INITIAL.
    INSERT &amp;lt;table&amp;gt; FROM TABLE &amp;lt;itab&amp;gt;.
    IF sy-subrc = 0.    "data inserted successfully
       DESCRIBE TABLE...
    ELSE.               "data not inserted
       MESSAGE 'table insertion error' TYPE 'I'.
    ENDIF.
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;lt;REMOVED BY MODERATOR&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;teja&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Alvaro Tejada Galindo on Feb 21, 2008 4:33 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2008 10:07:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/handle-insert-exception/m-p/3408760#M818666</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-21T10:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Handle INSERT exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/handle-insert-exception/m-p/3408761#M818667</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;1. If you wish to handle the exception as an information message,then it will show as a popup window.On closing this window,you can proceed with the program as in a normal flow.To achieve this,you can write the following piece of code :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF itab_zdfkkwoh IS NOT INITIAL.&lt;/P&gt;&lt;P&gt;   INSERT zdfkkwoh FROM TABLE itab_zdfkkwoh.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   IF sy-subrc = 0.                         " Data inserted successfully&lt;/P&gt;&lt;P&gt;     DESCRIBE TABLE itab_zdfkkwoh LINES countb.&lt;/P&gt;&lt;P&gt;   ELSE.                                       " Data insertion failed&lt;/P&gt;&lt;P&gt;     message i001(00) with 'Row(s) with same primary key already exists'.&lt;/P&gt;&lt;P&gt;   ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ELSE.                                          " Table is initial&lt;/P&gt;&lt;P&gt;  message i001(00) with 'Table contains no data'.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. However,if  you want to raise the exception as an error message,then it will show at the bottom of the screen as a highlighted red field.If you don't rectify the error,the program won't proceed.To achieve this,just make the modification in the message text as :&lt;/P&gt;&lt;P&gt;         -&lt;/P&gt;&lt;HR originaltext="----------------------" /&gt;&lt;P&gt;     message e001(00) with 'Row(s) with same primary key already exists'.&lt;/P&gt;&lt;P&gt;         -&lt;/P&gt;&lt;HR originaltext="-----------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. If you are writing this piece of code inside a function module,then you can raise exception as :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF itab_zdfkkwoh IS NOT INITIAL.&lt;/P&gt;&lt;P&gt;   INSERT zdfkkwoh FROM TABLE itab_zdfkkwoh.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   IF sy-subrc = 0.                         " Data inserted successfully&lt;/P&gt;&lt;P&gt;     DESCRIBE TABLE itab_zdfkkwoh LINES countb.&lt;/P&gt;&lt;P&gt;   ELSE.                                       " Data insertion failed&lt;/P&gt;&lt;P&gt;     RAISE insertion_error.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ELSE.                                          " Table is initial&lt;/P&gt;&lt;P&gt;   RAISE no_data.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here,'insertion_error' &amp;amp; 'no_data' are 2 exceptions that you need to define in the exceptions tab of funtion module definition.They will have sy-subrc values as 1 &amp;amp; 2(if no other exception is defined).&lt;/P&gt;&lt;P&gt;   You can handle this exceptions when you call the function module.At the end of function module code,write as :&lt;/P&gt;&lt;P&gt;       case sy-subrc.&lt;/P&gt;&lt;P&gt;           when  0.&lt;/P&gt;&lt;P&gt;          &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; Proceed further&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;           when 1.&lt;/P&gt;&lt;P&gt;           &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;insertion_error is raised.Handle the error.*&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;             message i001(00) with 'Row(s) with same primary key already exists'.&lt;/P&gt;&lt;P&gt;           when 2.&lt;/P&gt;&lt;P&gt;           &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;no_data raised.*&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;           message i001(00) with 'Table contains no data'.&lt;/P&gt;&lt;P&gt;       endcase.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;  Kaveri.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2008 11:04:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/handle-insert-exception/m-p/3408761#M818667</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-21T11:04:14Z</dc:date>
    </item>
  </channel>
</rss>

