<?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: instance of in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/instance-of/m-p/3634961#M875391</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;P&gt;To downcast you can use the operator &lt;STRONG&gt;?=&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is an example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: ref1 TYPE REF TO object,
  ref2 TYPE REF TO class.

ref2 ?= ref1.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And to catch errors you can use the following.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CATCH SYSTEM-EXCEPTIONS move_cast_error = 4.
  ref2 ?= ref1.
ENDCATCH.
IF sy-subrc NE 0.
  WRITE 'Error when casting'.
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 Apr 2008 18:11:44 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-04-11T18:11:44Z</dc:date>
    <item>
      <title>instance of</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/instance-of/m-p/3634960#M875390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would like to know what is the equivalent in abap object of the "instance of" of Java, because I have an object upcasted and I want to know if i am able to downcast it, thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2008 18:03:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/instance-of/m-p/3634960#M875390</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-11T18:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: instance of</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/instance-of/m-p/3634961#M875391</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;P&gt;To downcast you can use the operator &lt;STRONG&gt;?=&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is an example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: ref1 TYPE REF TO object,
  ref2 TYPE REF TO class.

ref2 ?= ref1.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And to catch errors you can use the following.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CATCH SYSTEM-EXCEPTIONS move_cast_error = 4.
  ref2 ?= ref1.
ENDCATCH.
IF sy-subrc NE 0.
  WRITE 'Error when casting'.
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2008 18:11:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/instance-of/m-p/3634961#M875391</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-11T18:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: instance of</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/instance-of/m-p/3634962#M875392</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;P&gt;On ECC 6.0 there is a static class method available which could be used as the &lt;EM&gt;InstanceOf&lt;/EM&gt; equivalent.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZUS_SDN_IS_INSTANCE_OF
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Thread: instance of
*&amp;amp; &amp;lt;a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="819410"&amp;gt;&amp;lt;/a&amp;gt;
*&amp;amp;---------------------------------------------------------------------*

REPORT  zus_sdn_is_instance_of.

TYPE-POOLS: abap.


DATA: go_msglist      TYPE REF TO cl_reca_message_list,
      gd_msg          TYPE bapi_msg.

PARAMETER:
  p_class   TYPE seoclsname  DEFAULT 'IF_RECA_MESSAGE_LIST'.


START-OF-SELECTION.

  go_msglist ?= cf_reca_message_list=&amp;gt;create( ).

  IF ( cl_wdy_wb_reflection_helper=&amp;gt;is_instance_of(
        object    = go_msglist
        type_name = p_class ) = abap_true ).
    concatenate 'Is instance of' p_class
      into gd_msg SEPARATED BY space.
    MESSAGE gd_msg TYPE 'I'.
  ELSE.
    concatenate 'Is NOT instance of' p_class
      into gd_msg SEPARATED BY space.
    MESSAGE gd_msg TYPE 'I'.
  ENDIF.


END-OF-SELECTION.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, please note that this class may be only used in a rather restricted sense related to WebDynpro.&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;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2008 18:31:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/instance-of/m-p/3634962#M875392</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2008-04-11T18:31:48Z</dc:date>
    </item>
  </channel>
</rss>

