<?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: How to declare a class object which will be created dynamically. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-declare-a-class-object-which-will-be-created-dynamically/m-p/7293993#M1533151</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA:
lo_content TYPE REF TO data .

if class 'cl_ap_a2x_service_manager' exists.(using a FM SEO_CLASS_GET)
CREATE DATA lo_content TYPE REF TO ('CL_ABAP_STRUCTDESCR').
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 27 Sep 2010 10:20:06 GMT</pubDate>
    <dc:creator>SuhaSaha</dc:creator>
    <dc:date>2010-09-27T10:20:06Z</dc:date>
    <item>
      <title>How to declare a class object which will be created dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-declare-a-class-object-which-will-be-created-dynamically/m-p/7293992#M1533150</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;The following code snippet does not work. How can i declare the variable lo_content so that&lt;/P&gt;&lt;P&gt;i can achieve the object creation based on class availability.&lt;/P&gt;&lt;P&gt;********************************************************************************&lt;/P&gt;&lt;P&gt;DATA:    &lt;/P&gt;&lt;P&gt;    lo_content            TYPE REF TO data .&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt;if class 'cl_ap_a2x_service_manager' exists.(using a FM SEO_CLASS_GET)&lt;/P&gt;&lt;P&gt;     CREATE OBJECT lo_content TYPE ('cl_ap_a2x_service_manager').&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;********************************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I cannot declare it as:    lo_content            TYPE REF TO cl_ap_a2x_service_manager .&lt;/P&gt;&lt;P&gt;I will not allow to activate the code as class cl_ap_a2x_service_manager doesnot exist in the same system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bikash.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Sep 2010 10:10:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-declare-a-class-object-which-will-be-created-dynamically/m-p/7293992#M1533150</guid>
      <dc:creator>bikash_bansal</dc:creator>
      <dc:date>2010-09-27T10:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to declare a class object which will be created dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-declare-a-class-object-which-will-be-created-dynamically/m-p/7293993#M1533151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA:
lo_content TYPE REF TO data .

if class 'cl_ap_a2x_service_manager' exists.(using a FM SEO_CLASS_GET)
CREATE DATA lo_content TYPE REF TO ('CL_ABAP_STRUCTDESCR').
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Sep 2010 10:20:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-declare-a-class-object-which-will-be-created-dynamically/m-p/7293993#M1533151</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-09-27T10:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to declare a class object which will be created dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-declare-a-class-object-which-will-be-created-dynamically/m-p/7293994#M1533152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are mixing &lt;STRONG&gt;data references&lt;/STRONG&gt; (type ref to DATA) with &lt;STRONG&gt;object references&lt;/STRONG&gt; (type ref to OBJECT). The latter should be used in this case (so that any &lt;STRONG&gt;object&lt;/STRONG&gt; type can be stored in this reference, not any &lt;STRONG&gt;data&lt;/STRONG&gt; ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA:
lo_content TYPE REF TO object .

CREATE OBJECT lo_content TYPE ('CL_AP_A2X_SERVICE_MANAGER').
&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>Mon, 27 Sep 2010 10:32:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-declare-a-class-object-which-will-be-created-dynamically/m-p/7293994#M1533152</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2010-09-27T10:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to declare a class object which will be created dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-declare-a-class-object-which-will-be-created-dynamically/m-p/7293995#M1533153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; You are mixing &lt;STRONG&gt;data references&lt;/STRONG&gt; (type ref to DATA) with &lt;STRONG&gt;object references&lt;/STRONG&gt; (type ref to OBJECT). The latter should be used in this case (so that any &lt;STRONG&gt;object&lt;/STRONG&gt; type can be stored in this reference, not any &lt;STRONG&gt;data&lt;/STRONG&gt; )&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hey Marcin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was about to correct my post &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt; Anyway today i had my first experience with generic object reference variable (OBJECT) !!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA:
lo_content TYPE REF TO object,
it_bdc_msg TYPE ZLMT_LINE.

FIELD-SYMBOLS: &amp;lt;attr&amp;gt; TYPE ANY.

CREATE OBJECT lo_content TYPE ('ZCL_CALL_TRANSACTION')
EXPORTING IM_TRANSACTION = 'SE11'.

CALL METHOD lo_content-&amp;gt;('GET_BDC_MESSAGES')
RECEIVING RE_BDC_MESSAGES = it_bdc_msg.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Sep 2010 10:41:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-declare-a-class-object-which-will-be-created-dynamically/m-p/7293995#M1533153</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-09-27T10:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to declare a class object which will be created dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-declare-a-class-object-which-will-be-created-dynamically/m-p/7293996#M1533154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No worries Suhas &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;DEL&gt;One thing I would like to point at. I think these two statements are syntatically incorrect&lt;/DEL&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE OBJECT lo_content TYPE ('ZCL_CALL_TRANSACTION')&lt;/P&gt;&lt;P&gt;EXPORTING IM_TRANSACTION = 'SE11'.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;CALL METHOD lo_content-&amp;gt;('GET_BDC_MESSAGES')&lt;/P&gt;&lt;P&gt;RECEIVING RE_BDC_MESSAGES = it_bdc_msg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;DEL&gt;This is because you are providing the class/method name dynamically, but its interface statically. Syntax checker will not recognize this signature as a valid one, unless it knows the name of class/method it is reffering to - as this comes during runtime, the interface parameters must also be provided dynamically.&lt;/DEL&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS: I just spotted in one of my programs that I was wrong with the above statement. Interface can be statical even class/method is provided dynamically. It is similar to calling FM where we deliver its name dynamically but interface is static. Sorry for this confusion&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Marcin Pciak on Sep 27, 2010 1:00 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Sep 2010 10:49:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-declare-a-class-object-which-will-be-created-dynamically/m-p/7293996#M1533154</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2010-09-27T10:49:52Z</dc:date>
    </item>
  </channel>
</rss>

