<?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: Retrieve instance( object ) from table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-instance-object-from-table/m-p/5671348#M1289639</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can try like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: lo_cont type ref to cl_bsp_controller2,
      lo_inv type ref to zcl_invoice.
DATA: lo_type TYPE REF TO cl_abap_typedescr,
      lo_cast_error TYPE REF TO cx_sy_move_cast_error.

loop at t_models into la_models.
* Get the absolute name from object ref.
  lo_cont = la_models-object.
  lo_type = cl_abap_classdescr=&amp;gt;describe_by_object_ref( lo_cont ).

* attribute ABSOLUTE_NAME of the LO_TYPE will give you the exact type
* Use this attribute to get to know your actual class.
  try.
      lo_inv ?= lo_cont.
   CATCH cx_sy_move_cast_error INTO lo_cast_error.
  entry.
endloop.  
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Jun 2009 13:26:13 GMT</pubDate>
    <dc:creator>naimesh_patel</dc:creator>
    <dc:date>2009-06-02T13:26:13Z</dc:date>
    <item>
      <title>Retrieve instance( object ) from table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-instance-object-from-table/m-p/5671347#M1289638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table m_models which has two fields, model_id and instance. Model id is a string and instance is an instance of a class, it can be either workitem class - ZWorkitem, or invoice classs zinvoice class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now both of above classes are inherited from cl_bsp_controller2, and some of their data is different.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I want to retrieve instance of the class from table when model id is invoice, but i am not able to speficy the class type for the object that should store the instance, if i use  cl_bsp_controller2 i miss some data and when i use zinvoice it gives me another error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please advise?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can provide more details of the issue if you want.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jun 2009 08:11:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-instance-object-from-table/m-p/5671347#M1289638</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-02T08:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve instance( object ) from table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-instance-object-from-table/m-p/5671348#M1289639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can try like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: lo_cont type ref to cl_bsp_controller2,
      lo_inv type ref to zcl_invoice.
DATA: lo_type TYPE REF TO cl_abap_typedescr,
      lo_cast_error TYPE REF TO cx_sy_move_cast_error.

loop at t_models into la_models.
* Get the absolute name from object ref.
  lo_cont = la_models-object.
  lo_type = cl_abap_classdescr=&amp;gt;describe_by_object_ref( lo_cont ).

* attribute ABSOLUTE_NAME of the LO_TYPE will give you the exact type
* Use this attribute to get to know your actual class.
  try.
      lo_inv ?= lo_cont.
   CATCH cx_sy_move_cast_error INTO lo_cast_error.
  entry.
endloop.  
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jun 2009 13:26:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-instance-object-from-table/m-p/5671348#M1289639</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2009-06-02T13:26:13Z</dc:date>
    </item>
  </channel>
</rss>

