<?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: Get class Instance, and then get hers attributes in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-class-instance-and-then-get-hers-attributes/m-p/5793070#M1310293</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Uwe,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but does not work.&lt;/P&gt;&lt;P&gt;Compiler say everything ok, but error occured when executing the instruction&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  lo_left_controller ?= parent.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Davide&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Jul 2009 11:07:22 GMT</pubDate>
    <dc:creator>former_member998879</dc:creator>
    <dc:date>2009-07-03T11:07:22Z</dc:date>
    <item>
      <title>Get class Instance, and then get hers attributes</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-class-instance-and-then-get-hers-attributes/m-p/5793064#M1310287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gurus,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i'm new to ABAP Object,&lt;/P&gt;&lt;P&gt;creating an a BSP whit MVC controller i've try to implement the class controller,&lt;/P&gt;&lt;P&gt;but on a method of it i want to get instance of the class parents:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the class that i implement is an extension of CL_BSP_CONTROLLER2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this class in the method DO_REQUEST ( for example ) i try to get the instance of the class&lt;/P&gt;&lt;P&gt;parent ( and i got it! ) using this syntax:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  data: Parent type ref to IF_BSP_DISPATCHER,   " type take from attribute M_PARENT of the class
  
 Parent = ME-&amp;gt;M_PARENT.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In debug i see that 'Parent'  get rightly the class parent instance but than i want do this:&lt;/P&gt;&lt;P&gt;(i want get the sub controller of the main contoller 'parent', in debug i can see everything fine)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
   SubController = Parent-&amp;gt;GET_ATTRIBUTE(LEFT_CONTROLLER).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the compiler say that the class instance 'Parent' has no methods and no attribute. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i've try other syntax like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
    call METHOD Parent_&amp;gt;GET_ATTRIBUTE
        IMPORTING
     LEFT_CONTROLLER)

  call METHOD ME-&amp;gt;M_PARENT-&amp;gt;GET_CONTROLLER
   EXPORTING
     CONTROLLER_ID = 'search'
   IMPORTING
     CONTROLLER_INSTANCE = Parent2
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No one work!&lt;/P&gt;&lt;P&gt;How can i do?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here screnshot of that i see in debug mode, and that i want get:&lt;/P&gt;&lt;P&gt;&lt;A href="http://img190.imageshack.us/i/1debugscreen.jpg/" target="test_blank"&gt;http://img190.imageshack.us/i/1debugscreen.jpg/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://img10.imageshack.us/i/2debugscreen.jpg/" target="test_blank"&gt;http://img10.imageshack.us/i/2debugscreen.jpg/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Davide&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jul 2009 08:47:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-class-instance-and-then-get-hers-attributes/m-p/5793064#M1310287</guid>
      <dc:creator>former_member998879</dc:creator>
      <dc:date>2009-07-03T08:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: Get class Instance, and then get hers attributes</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-class-instance-and-then-get-hers-attributes/m-p/5793065#M1310288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The parent of CL_BSP_CONTROLLER2 is of type IF_BSP_DISPATCHER.&lt;/P&gt;&lt;P&gt;And IF_BSP_DISPATCHER definitely doesn't have any property LEFT_CONTROLLER. So I think you are looking at the wrong place.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Access LEFT_CONTROLLER attribute of class ZGEO_CONTROLLER_MAIN. I think instance of ZGEO_CONTROLLER_MAIN is available in program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Pawan Kesari on Jul 3, 2009 4:03 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jul 2009 10:26:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-class-instance-and-then-get-hers-attributes/m-p/5793065#M1310288</guid>
      <dc:creator>Pawan_Kesari</dc:creator>
      <dc:date>2009-07-03T10:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Get class Instance, and then get hers attributes</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-class-instance-and-then-get-hers-attributes/m-p/5793066#M1310289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Pawan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;classes ref to CL_BSP_CONTROLLER2 like my controller class, have an attribute &lt;/P&gt;&lt;P&gt;M_PARENT type IF_BSP_DISPATCHER.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the class is a subclass of an main class it has the M_PARENT attribute containing the instance of the parent class,&lt;/P&gt;&lt;P&gt;i can see in debug mode ( here example: &lt;A href="http://img40.imageshack.us/img40/1648/3debugscreen.jpg" target="test_blank"&gt;http://img40.imageshack.us/img40/1648/3debugscreen.jpg&lt;/A&gt; )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i can get this attribute:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  data: Parent type ref to IF_BSP_DISPATCHER,   " type take from attribute M_PARENT of the class
  
 Parent = ME-&amp;gt;M_PARENT.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but  the interface IF_BSP_DISPATCHER has no attribute and no method defined, and if i declare 'Parent' as type ref to&lt;/P&gt;&lt;P&gt;CL_BSP_CONTROLLER2 the compiler return error &lt;/P&gt;&lt;P&gt;      &amp;lt;=&amp;gt;      "The type of "PARENT" cannot be converted to the type of "ME-&amp;gt;M_PARENT". "&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Davide&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jul 2009 10:47:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-class-instance-and-then-get-hers-attributes/m-p/5793066#M1310289</guid>
      <dc:creator>former_member998879</dc:creator>
      <dc:date>2009-07-03T10:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: Get class Instance, and then get hers attributes</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-class-instance-and-then-get-hers-attributes/m-p/5793067#M1310290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From screen it appear that M_PARENT attribute has instance of class ZGEO_CONTROLLER_MAIN.&lt;/P&gt;&lt;P&gt;I wonder if you could just do it this way&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: Parent type ref to ZGEO_CONTROLLER_MAIN.
Parent = ME-&amp;gt;M_PARENT .&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jul 2009 11:00:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-class-instance-and-then-get-hers-attributes/m-p/5793067#M1310290</guid>
      <dc:creator>Pawan_Kesari</dc:creator>
      <dc:date>2009-07-03T11:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: Get class Instance, and then get hers attributes</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-class-instance-and-then-get-hers-attributes/m-p/5793068#M1310291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Davide&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Without knowing the relation between the classes (hierarchy, interfaces) it is difficult to understand your problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assuming that your left controller always is an instance of class ZGEO_CONTROLLER_SEARCH (assumption: implements interface IF_BSP_DISPATCHER) you could try the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: 
  Parent type ref to IF_BSP_DISPATCHER,   " type take from attribute M_PARENT of the class
  lo_left_controller        TYPE REF TO zgeo_controller_search.


 Parent = ME-&amp;gt;M_PARENT.

lo_left_controller ?= parent.

CALL METHOD lo_left_controller-&amp;gt;...
&lt;/CODE&gt;&lt;/PRE&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, 03 Jul 2009 11:02:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-class-instance-and-then-get-hers-attributes/m-p/5793068#M1310291</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2009-07-03T11:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Get class Instance, and then get hers attributes</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-class-instance-and-then-get-hers-attributes/m-p/5793069#M1310292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;type ZGEO_CONTROLLER_MAIN is a type ref to CL_BSP_CONTROLLER2, and just i say above do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: Parent type ref to ZGEO_CONTROLLER_MAIN.
Parent = ME-&amp;gt;M_PARENT .
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;doesn't work.    "The type of "PARENT" cannot be converted to the type of "ME-&amp;gt;M_PARENT"."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks however for you help!&lt;/P&gt;&lt;P&gt;Davide&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jul 2009 11:06:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-class-instance-and-then-get-hers-attributes/m-p/5793069#M1310292</guid>
      <dc:creator>former_member998879</dc:creator>
      <dc:date>2009-07-03T11:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: Get class Instance, and then get hers attributes</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-class-instance-and-then-get-hers-attributes/m-p/5793070#M1310293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Uwe,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but does not work.&lt;/P&gt;&lt;P&gt;Compiler say everything ok, but error occured when executing the instruction&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  lo_left_controller ?= parent.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Davide&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jul 2009 11:07:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-class-instance-and-then-get-hers-attributes/m-p/5793070#M1310293</guid>
      <dc:creator>former_member998879</dc:creator>
      <dc:date>2009-07-03T11:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: Get class Instance, and then get hers attributes</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-class-instance-and-then-get-hers-attributes/m-p/5793071#M1310294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Davide&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There must be a simple way using casting but - as I said already - without knowing the relations and interfaces of the classes it is difficult to find the solution.&lt;/P&gt;&lt;P&gt;Alternatively, you may call the method dynamically.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: 
  Parent type ref to IF_BSP_DISPATCHER,   " type take from attribute M_PARENT of the class
  lo_obj        TYPE REF TO object,   " root class
 ld_method  TYPE string.
 
 Parent = ME-&amp;gt;M_PARENT.
 
lo_obj ?= parent.

ld_method = '&amp;lt;name of public method&amp;gt;'.
 
CALL METHOD lo_obj-&amp;gt;(ld_method)...

&lt;/CODE&gt;&lt;/PRE&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, 03 Jul 2009 19:41:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-class-instance-and-then-get-hers-attributes/m-p/5793071#M1310294</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2009-07-03T19:41:46Z</dc:date>
    </item>
  </channel>
</rss>

