<?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: TRY and ENDTRY in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/try-and-endtry/m-p/2907333#M683989</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;Its mainly used for catch the Exceptions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TRY. &lt;/P&gt;&lt;P&gt;    [try_block] &lt;/P&gt;&lt;P&gt;  [CATCH cx_class1 cx_class2 ... [INTO oref]. &lt;/P&gt;&lt;P&gt;    [catch_block]] &lt;/P&gt;&lt;P&gt;    ... &lt;/P&gt;&lt;P&gt;  [CLEANUP [INTO oref]. &lt;/P&gt;&lt;P&gt;    [cleanup_block]] &lt;/P&gt;&lt;P&gt;ENDTRY. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 Oct 2007 09:59:39 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-10-11T09:59:39Z</dc:date>
    <item>
      <title>TRY and ENDTRY</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/try-and-endtry/m-p/2907332#M683988</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;What is the use of TRY and ENDTRY statement?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2007 09:57:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/try-and-endtry/m-p/2907332#M683988</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-11T09:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: TRY and ENDTRY</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/try-and-endtry/m-p/2907333#M683989</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;Its mainly used for catch the Exceptions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TRY. &lt;/P&gt;&lt;P&gt;    [try_block] &lt;/P&gt;&lt;P&gt;  [CATCH cx_class1 cx_class2 ... [INTO oref]. &lt;/P&gt;&lt;P&gt;    [catch_block]] &lt;/P&gt;&lt;P&gt;    ... &lt;/P&gt;&lt;P&gt;  [CLEANUP [INTO oref]. &lt;/P&gt;&lt;P&gt;    [cleanup_block]] &lt;/P&gt;&lt;P&gt;ENDTRY. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2007 09:59:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/try-and-endtry/m-p/2907333#M683989</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-11T09:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: TRY and ENDTRY</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/try-and-endtry/m-p/2907334#M683990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Basic form &lt;/P&gt;&lt;P&gt;TRY. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;You catch class-based exceptions in the statement block enclosed by the TRY and ENDTRY statements. To catch these exceptions, you define handlers within the specified TRY block. You introduce a handler using a CATCH statement, followed by the exception classes to be caught and the associated handler code. After the CATCH clauses, you can declare a CLEANUP clause. The statements in the latter clause will be executed if an exception is caught outsidethe TRY block. The structure of the TRY block is as follows: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TRY. &lt;/P&gt;&lt;P&gt;  ... guarded section &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;CATCH cx11 ... cx1n [INTO ex1]. &lt;/P&gt;&lt;P&gt;  ... handlers for exceptions cx11 to cx1n &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;CATCH cx21 ... cx2m [INTO ex2]. &lt;/P&gt;&lt;P&gt;  ... handlers for exceptions cx21 bis cx2m &lt;/P&gt;&lt;P&gt;... other handlers &lt;/P&gt;&lt;P&gt;CLEANUP. &lt;/P&gt;&lt;P&gt;  ... cleanup block &lt;/P&gt;&lt;P&gt;ENDTRY. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TRY statement is used when you expect some error/exception condition but not sure of which type of error may be present in a code block.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in that case just wrap the code block in TRY ..ENDTRY block&lt;/P&gt;&lt;P&gt;see this sample code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TRY.&lt;/P&gt;&lt;P&gt;SORT T_ERGEB-MSG_T_SAP_ACTIVITY-ITEM DESCENDING.&lt;/P&gt;&lt;P&gt;DELETE ADJACENT DUPLICATES FROM T_ERGEB-MSG_T_SAP_ACTIVITY-ITEM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL METHOD ZCO_SAP_ACTIVITY_TOMX=&amp;gt;EXECUTE_ASYNCHRONOUS&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;OUTPUT = T_ERGEB&lt;/P&gt;&lt;P&gt;CONTROLLER = L_CONTROLLER.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COMMIT WORK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CATCH CX_AI_SYSTEM_FAULT INTO L_SYS_EXCEPTION.&lt;/P&gt;&lt;P&gt;SY-MSGV1 = L_SYS_EXCEPTION-&amp;gt;ERRORTEXT.&lt;/P&gt;&lt;P&gt;SUBRC = 1.&lt;/P&gt;&lt;P&gt;EXIT.&lt;/P&gt;&lt;P&gt;ENDTRY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here we are expecting that this code may generate a CX_AI_SYSTEM_FAULT type of exception. to handle this we have written a catch block.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;error of type CX_AI_SYSTEM_FAULT will be handled by this catch block &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*****************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check this thread&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.sdn.sap.com/click.jspa?searchID=93818&amp;amp;messageID=2288302" target="test_blank"&gt;https://forums.sdn.sap.com/click.jspa?searchID=93818&amp;amp;messageID=2288302&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The TRY block is split into different sections using the CATCH and CLEANUP clauses.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2007 10:01:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/try-and-endtry/m-p/2907334#M683990</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-11T10:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: TRY and ENDTRY</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/try-and-endtry/m-p/2907335#M683991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;     For some cases, there might be possiblity of dump. hence you go for the statment with in try and endtry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Niyaz&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2007 10:01:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/try-and-endtry/m-p/2907335#M683991</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-11T10:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: TRY and ENDTRY</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/try-and-endtry/m-p/2907336#M683992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Its another way of handling error.&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;do_something.&lt;/P&gt;&lt;P&gt;if sy-subrc &amp;gt; 0.&lt;/P&gt;&lt;P&gt;  do_error_handling.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try.&lt;/P&gt;&lt;P&gt;  do_something.&lt;/P&gt;&lt;P&gt;catch &amp;lt;exception&amp;gt;&lt;/P&gt;&lt;P&gt;  do_error_handling.&lt;/P&gt;&lt;P&gt;endtry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the advantage is that you can handle system error like division by zero or conversion errors without havening an abend.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2007 10:02:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/try-and-endtry/m-p/2907336#M683992</guid>
      <dc:creator>rainer_hbenthal</dc:creator>
      <dc:date>2007-10-11T10:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: TRY and ENDTRY</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/try-and-endtry/m-p/2907337#M683993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Hema,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are two options for raising class-based exceptions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.       System-driven raising in the runtime environment&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.       Program-driven raising in the ABAP program&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax for TRY .. ENDTRY construct &lt;/P&gt;&lt;P&gt;TRY.                                                             &lt;/P&gt;&lt;P&gt;    CALL METHOD o1-&amp;gt;m1.                                          &lt;/P&gt;&lt;P&gt;    PERFORM f1.                                                  &lt;/P&gt;&lt;P&gt;  CATCH cx_root.  "Handler for all exceptions                    &lt;/P&gt;&lt;P&gt;       " ABAP code(What to do when error occures)........        &lt;/P&gt;&lt;P&gt;ENDTRY.                                                                                &lt;/P&gt;&lt;P&gt;FORM f1 RAISING cx_my.                                           &lt;/P&gt;&lt;P&gt;  TRY.                                                           &lt;/P&gt;&lt;P&gt;    IF ...... RAISE EXCEPTION TYPE cx_my2. ENDIF.                &lt;/P&gt;&lt;P&gt;      CALL METHOD o1-&amp;gt;m3.                                        &lt;/P&gt;&lt;P&gt;  CATCH cx_my1 cx_my3 INTO ex.                                   &lt;/P&gt;&lt;P&gt;    RAISE EXCEPTION TYPE cx_my4.                                 &lt;/P&gt;&lt;P&gt;  CATCH cx_my4.                                                  &lt;/P&gt;&lt;P&gt;     "Handler for exceptions of type cx_my4                      &lt;/P&gt;&lt;P&gt;     " ABAP code(What to do when error occures)........          &lt;/P&gt;&lt;P&gt;  CLEANUP.                                                       &lt;/P&gt;&lt;P&gt;     "Cleanup section, used to restore to a consistant state     &lt;/P&gt;&lt;P&gt;     " ABAP code........                                         &lt;/P&gt;&lt;P&gt;  ENDTRY.                                                        &lt;/P&gt;&lt;P&gt;ENDFORM.                                                         &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;a href="http://help.sap.com/saphelp_nw04s/helpdata/en/83/636d2012fc11d5991e00508b5d5211/frameset.htm"&amp;gt;TRY and Endtry&amp;lt;/a&amp;gt;&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;Sathish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2007 10:02:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/try-and-endtry/m-p/2907337#M683993</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-11T10:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: TRY and ENDTRY</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/try-and-endtry/m-p/2907338#M683994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this simple example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: result TYPE i,&lt;/P&gt;&lt;P&gt;      number TYPE i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CATCH SYSTEM-EXCEPTIONS arithmetic_errors = 4&lt;/P&gt;&lt;P&gt;                        OTHERS = 8.&lt;/P&gt;&lt;P&gt;  result = 1 / number.&lt;/P&gt;&lt;P&gt;ENDCATCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;write:/ 'Exception caught'.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if usefull.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2007 10:03:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/try-and-endtry/m-p/2907338#M683994</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-11T10:03:42Z</dc:date>
    </item>
  </channel>
</rss>

