<?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: CREATE OBJECT obj and EXCEPTIONS problem in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404285#M1547199</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;CREATE OBJECT obj                 //in constructor there should start method called with EXCEPTIONS clause ...
   EXPORTING
     data = data.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If this one fails... then you will still get a dump on &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CALL METHOD obj-&amp;gt;start
   EXCEPTIONS
      error = 1.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 21 Oct 2010 10:49:45 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-10-21T10:49:45Z</dc:date>
    <item>
      <title>CREATE OBJECT obj and EXCEPTIONS problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404274#M1547188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a problem with my program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CREATE OBJECT obj
  EXPORTING
    ls_record_local = ls_record
  EXCEPTIONS
    error = 1.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When there is no exception everything is fine, but when the sy-subrc = 1, there is no possibility to trigger any other method like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CALL METHOD obj-&amp;gt;get_data.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;System says that obj is initial and it goes to dump.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea how to prevent this dump How can I have the reference to my object after exception has been throwed ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Oct 2010 09:43:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404274#M1547188</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-21T09:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE OBJECT obj and EXCEPTIONS problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404275#M1547189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I bet the exception is raised because the object could not be created. So... it's impossible to call any methods of that object: it doesn't exist.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To prevent your error: make sure you only call the method(s) when you're sure the object exists (no exception raised).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Oct 2010 09:47:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404275#M1547189</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-21T09:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE OBJECT obj and EXCEPTIONS problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404276#M1547190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;CREATE OBJECT command creates an instance of the class. If there is a problem in instantiating the class an EXCEPTION is raised &amp;amp; the class doesn't get instantiated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case you can't use the instance attributes / methods of the class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CREATE OBJECT obj
  EXPORTING
    ls_record_local = ls_record
  EXCEPTIONS
    error = 1.

IF sy-subrc NE 0.
  MESSAGE 'Error Instantiating the class' TYPE 'E'.
ENDIF.

CALL METHOD obj-&amp;gt;method.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope i'm clear.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Suhas Saha on Oct 21, 2010 3:40 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Oct 2010 09:57:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404276#M1547190</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-10-21T09:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE OBJECT obj and EXCEPTIONS problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404277#M1547191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Catch the exception in try endtry block and if its caught donot proceed further.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Oct 2010 10:07:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404277#M1547191</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2010-10-21T10:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE OBJECT obj and EXCEPTIONS problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404278#M1547192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Keshav,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is not class based exception. He doesn't need the TRY ... CATCH block to catch these exception. A SY-SUBRC check should suffice.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Oct 2010 10:09:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404278#M1547192</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-10-21T10:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE OBJECT obj and EXCEPTIONS problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404279#M1547193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Suhas,&lt;/P&gt;&lt;P&gt;In this case Exceptions can be handled in instance constructors also. A sy-subrc check will also work &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Oct 2010 10:13:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404279#M1547193</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2010-10-21T10:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE OBJECT obj and EXCEPTIONS problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404280#M1547194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;In this case Exceptions can be handled in instance constructors also&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm sorry i don't get your point. If you could elaborate! Anyway there are some catchable runtime exception which can be caught using the exception class CX_SY_CREATE_OBJECT_ERROR. Some thing like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TRY .
    CREATE OBJECT obj
      EXPORTING
        ls_record_local = ls_record
      EXCEPTIONS
        error           = 1.
  CATCH cx_sy_create_object_error INTO lo_exception.
ENDTRY.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Suhas Saha on Oct 21, 2010 3:58 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Oct 2010 10:27:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404280#M1547194</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-10-21T10:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE OBJECT obj and EXCEPTIONS problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404281#M1547195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all for the responses.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The thing is that I must call some method after exception has been triggered so sy-subrc checking is enough.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think that in my case following solution should be ok :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CREATE OBJECT obj                 //in constructor there should start method called with EXCEPTIONS clause ...
   EXPORTING
     data = data.

CALL METHOD obj-&amp;gt;start
   EXCEPTIONS
      error = 1.
 IF sy-subrc = 1.
     CALL METHOD obj-&amp;gt;method .... //because object is still referenced
 ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Oct 2010 10:35:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404281#M1547195</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-21T10:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE OBJECT obj and EXCEPTIONS problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404282#M1547196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;NO!!!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IF SY_SUBRC EQ 0.

call your method...

ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If SUBRC &amp;lt;&amp;gt; 0 then the object doesn't exist.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT: Never mind... responded too fast. IN this example your object does exist (at least that's what i hope)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Maen Anachronos on Oct 21, 2010 12:40 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Oct 2010 10:39:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404282#M1547196</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-21T10:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE OBJECT obj and EXCEPTIONS problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404283#M1547197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Make some mistake :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course constructor should have empty body, and the start method is calling within the program which create the object.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Oct 2010 10:47:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404283#M1547197</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-21T10:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE OBJECT obj and EXCEPTIONS problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404284#M1547198</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Daniel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the object of the class can't be created then the object reference variable is set to it's initial value. Only if the CREATE OBJECT command is successful the SY-SUBRC is set to 0, for other cases it'll have non-zero values. You should check SY-SUBRC after your CREATE OBJECT statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read the F1 help for CREATE OBJECT for better understanding.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Oct 2010 10:48:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404284#M1547198</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-10-21T10:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE OBJECT obj and EXCEPTIONS problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404285#M1547199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;CREATE OBJECT obj                 //in constructor there should start method called with EXCEPTIONS clause ...
   EXPORTING
     data = data.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If this one fails... then you will still get a dump on &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CALL METHOD obj-&amp;gt;start
   EXCEPTIONS
      error = 1.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Oct 2010 10:49:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-object-obj-and-exceptions-problem/m-p/7404285#M1547199</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-21T10:49:45Z</dc:date>
    </item>
  </channel>
</rss>

