<?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: class based exception in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/class-based-exception/m-p/7627969#M1570935</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 have mentioned "In method's signature check the Exception Classes checkbox and give your exception class name there"..&lt;/P&gt;&lt;P&gt;So i have a exception class ZCX_A and there is a method NullHandler to handle the exception..In setdata method, i check for the initial values and if they are initial then i will raise exception type ZCX_A. It will be caught by catch ZCX_A into object. Then i would use call method object-&amp;gt;NullHandler. Now where should i enable the the Exception Classes checkbox? Whether in the method NullHandler of class ZCX_A or in the setdata method which actually raise the exception?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Feb 2011 05:01:08 GMT</pubDate>
    <dc:creator>lakshminarasimhan_n4</dc:creator>
    <dc:date>2011-02-17T05:01:08Z</dc:date>
    <item>
      <title>class based exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/class-based-exception/m-p/7627967#M1570933</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 have a class and the class has two methods, setdata and getdata.&lt;/P&gt;&lt;P&gt;The setdata method receives 2 input strings and updates a Z table.&lt;/P&gt;&lt;P&gt;Getdata outputs the data from the same Z table.&lt;/P&gt;&lt;P&gt;Now i want to handle run time errors. &lt;/P&gt;&lt;P&gt;so created the exception class and its super class is cx_static_check.&lt;/P&gt;&lt;P&gt;i have defined a method in exception class, it will print "parameters are blank",  if the passing parameter to setdata does not contain any value.&lt;/P&gt;&lt;P&gt;in the method setdata i have used inside a if endif..try..catch endtry. statement. &lt;/P&gt;&lt;P&gt;Try checks whether the values are blank, if blank it raise exception and that needs to be caught by the catch statement into an object reference. using the object refernce i call method and print statement "parameters are blank".&lt;/P&gt;&lt;P&gt;now i get error "no open try statement".but in the setdata method i have both try...endtry.&lt;/P&gt;&lt;P&gt;also i have a doubt regarding choosing the check box "class based exception" for a method.&lt;/P&gt;&lt;P&gt;Does the methos that handles exception should be checked "class based exception" or which method to be checked as "class based exception"?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Feb 2011 02:39:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/class-based-exception/m-p/7627967#M1570933</guid>
      <dc:creator>lakshminarasimhan_n4</dc:creator>
      <dc:date>2011-02-16T02:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: class based exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/class-based-exception/m-p/7627968#M1570934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To make this work you need:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) In exception class i.e. &lt;STRONG&gt;ZCX_CLA_TEST&lt;/STRONG&gt; on &lt;EM&gt;Text&lt;/EM&gt; tab add &lt;STRONG&gt;NO_PARAMETERS&lt;/STRONG&gt; with same description&lt;/P&gt;&lt;P&gt;2) In method's signature check the &lt;EM&gt;Exception Classes&lt;/EM&gt; checkbox and give your exception class name there&lt;/P&gt;&lt;P&gt;3) In method itself raise an exception with this textid&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
METHOD set_data.
  if i_param is not supplied or 
     i_param is initial.
"raise exception
      RAISE EXCEPTION TYPE zcx_cla_test
            EXPORTING textid = zcx_cla_test=&amp;gt;no_parameters.
  endif.
ENDMETHOD.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;4) In client program catch this exception and get its message&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA gr_exc TYPE REF TO zcx_cla_test.
DATA g_mess TYPE string.

TRY .
    z_cla_test=&amp;gt;set_data( ).
  CATCH zcx_cla_test INTO gr_exc.
    g_mess = gr_exc-&amp;gt;get_text( ).
    MESSAGE g_mess TYPE 'I'.
ENDTRY.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Feb 2011 08:43:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/class-based-exception/m-p/7627968#M1570934</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2011-02-16T08:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: class based exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/class-based-exception/m-p/7627969#M1570935</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 have mentioned "In method's signature check the Exception Classes checkbox and give your exception class name there"..&lt;/P&gt;&lt;P&gt;So i have a exception class ZCX_A and there is a method NullHandler to handle the exception..In setdata method, i check for the initial values and if they are initial then i will raise exception type ZCX_A. It will be caught by catch ZCX_A into object. Then i would use call method object-&amp;gt;NullHandler. Now where should i enable the the Exception Classes checkbox? Whether in the method NullHandler of class ZCX_A or in the setdata method which actually raise the exception?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Feb 2011 05:01:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/class-based-exception/m-p/7627969#M1570935</guid>
      <dc:creator>lakshminarasimhan_n4</dc:creator>
      <dc:date>2011-02-17T05:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: class based exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/class-based-exception/m-p/7627970#M1570936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You always have to list all exceptions that method can raise. So you need that in &lt;EM&gt;set_data&lt;/EM&gt; method. Only then you are able to raise an exception within its body.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the same as you would be using classical error in Function Module. When you call any FM which have the exception listed you get something like&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CALL FUNCTION ...
   IMPORTING ....
   EXCEPTIONS
      something_wrong = 1
      something_other_wrong = 2
      others = 3.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;See, here all exceptions are listed which FM can raise inside its body. The same situation is with methods and class based exceptions, but you embrace its call within TRY.,.CATCH block instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Feb 2011 07:46:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/class-based-exception/m-p/7627970#M1570936</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2011-02-17T07:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: class based exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/class-based-exception/m-p/7627971#M1570937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Answered&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Feb 2011 02:42:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/class-based-exception/m-p/7627971#M1570937</guid>
      <dc:creator>lakshminarasimhan_n4</dc:creator>
      <dc:date>2011-02-21T02:42:58Z</dc:date>
    </item>
  </channel>
</rss>

