<?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: Problem with TRY..ENDTRY block in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-try-endtry-block/m-p/1534446#M243936</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;Was my thread useful enough to solve ur problem??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 08 Sep 2006 04:50:06 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-09-08T04:50:06Z</dc:date>
    <item>
      <title>Problem with TRY..ENDTRY block</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-try-endtry-block/m-p/1534443#M243933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ABAP Experts:)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am expecting problems with TRY..ENDTRY block. What I need is when any kind of error occurs within a TRY..ENDTRY block then program should show a message and stop executing the program. I wrote the following code using class-based exceptions (CX_ROOT, that is defined as a handler for all exceptions):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TRY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT COUNT(*)&lt;/P&gt;&lt;P&gt;INTO lv_field_count&lt;/P&gt;&lt;P&gt;FROM (lv_from)&lt;/P&gt;&lt;P&gt;WHERE (lt_where_1).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CATCH CX_ROOT.&lt;/P&gt;&lt;P&gt;MESSAGE e003.&lt;/P&gt;&lt;P&gt;ENDTRY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But practically, it doesn't catch all possible errors (for example, runtime error CONVT_NO_NUMBER).&lt;/P&gt;&lt;P&gt;I tried to use old-fashioned SYSTEM-EXCEPTIONS for specific errors, but it didn't work too (it shows a runtime error and ignores my MESSAGE e003):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CATCH SYSTEM-EXCEPTIONS CONVERSION_ERRORS = 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT COUNT(*)&lt;/P&gt;&lt;P&gt;INTO lv_field_count&lt;/P&gt;&lt;P&gt;FROM (lv_from)&lt;/P&gt;&lt;P&gt;WHERE (lt_where_1).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDCATCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF SY-SUBRC = 1.&lt;/P&gt;&lt;P&gt;MESSAGE e003.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Currently I am using SAP GUI 6.40 version. I searched for help on this topic, and found, that:&lt;/P&gt;&lt;P&gt;"Starting with Release 6.10, exceptions are generally handled based on the class. Therefore, each catchable runtime error is assigned a predefined exception class. This allows you to catch this error like all catchable exceptions between the statements TRY..ENDTRY using the statement CATCH. This is the preferred method."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, it looks like my code should work. Any help is appreciated!&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;Santosh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Sep 2006 08:16:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-try-endtry-block/m-p/1534443#M243933</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-07T08:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with TRY..ENDTRY block</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-try-endtry-block/m-p/1534444#M243934</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;Your objective looks perfectly fine but lets do some fine tuning :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data : o_ref type ref to cx_root,
       msg type string.

TRY.

SELECT COUNT(*)
INTO lv_field_count
FROM (lv_from)
WHERE (lt_where_1).

CATCH CX_ROOT into o_ref.
ENDTRY.

if SY-SUBRC &amp;lt;&amp;gt; 0.
Msg = O_REF-&amp;gt;GET_TEXT( ).
write msg.
endif.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Sep 2006 09:46:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-try-endtry-block/m-p/1534444#M243934</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-07T09:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with TRY..ENDTRY block</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-try-endtry-block/m-p/1534445#M243935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Zapper &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Santosh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Sep 2006 13:05:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-try-endtry-block/m-p/1534445#M243935</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-07T13:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with TRY..ENDTRY block</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-try-endtry-block/m-p/1534446#M243936</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;Was my thread useful enough to solve ur problem??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Sep 2006 04:50:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-try-endtry-block/m-p/1534446#M243936</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-08T04:50:06Z</dc:date>
    </item>
  </channel>
</rss>

