<?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: runtime error while casting. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-while-casting/m-p/3283445#M785299</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My guess is you've something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;data: superclass_ref type ref to superclass,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;      &lt;EM&gt;subclass_instance  type ref to subclass.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;create object superclass_ref.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;subclass_instance ?= superclass_ref.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is that the object superclass_ref is of type superclass.  When you try to downcast, you can't because superclass doesn't have, for example, all the attributes of subclass.  In order to use down casting, the receiving object reference MUST be of the type of the subclass.  So you need something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;create object superclass_ref &lt;STRONG&gt;TYPE subclass.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;subclass_instance ?= superclass_ref.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 21 Jan 2008 09:58:57 GMT</pubDate>
    <dc:creator>matt</dc:creator>
    <dc:date>2008-01-21T09:58:57Z</dc:date>
    <item>
      <title>runtime error while casting.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-while-casting/m-p/3283444#M785298</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;  When i assign a superclass reference to subclass instance it raises runtime  error message which i hav mentioned below. &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;the statement which i used in the program is &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;subclass_instance ?= superclass_ref. " (DOWNCASTING)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;" It was tried to assign a reference to a rereference variable using the&lt;/P&gt;&lt;P&gt; 'CAST' operation ('?=' or 'MOVE ?TO').&lt;/P&gt;&lt;P&gt; However, the current content of the source variable does not fit into&lt;/P&gt;&lt;P&gt; the target variable."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can anyone tell me how to rectify this error. Thanks...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Joseph.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jan 2008 06:35:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-while-casting/m-p/3283444#M785298</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-21T06:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: runtime error while casting.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-while-casting/m-p/3283445#M785299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My guess is you've something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;data: superclass_ref type ref to superclass,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;      &lt;EM&gt;subclass_instance  type ref to subclass.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;create object superclass_ref.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;subclass_instance ?= superclass_ref.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is that the object superclass_ref is of type superclass.  When you try to downcast, you can't because superclass doesn't have, for example, all the attributes of subclass.  In order to use down casting, the receiving object reference MUST be of the type of the subclass.  So you need something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;create object superclass_ref &lt;STRONG&gt;TYPE subclass.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;subclass_instance ?= superclass_ref.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jan 2008 09:58:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/runtime-error-while-casting/m-p/3283445#M785299</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2008-01-21T09:58:57Z</dc:date>
    </item>
  </channel>
</rss>

