Get class Instance, and then get hers attributes

Advertisement

Get class Instance, and then get hers attributes
Hi Gurus,
i'm new to ABAP Object,
creating an a BSP whit MVC controller i've try to implement the class controller,
but on a method of it i want to get instance of the class parents:
the class that i implement is an extension of CL_BSP_CONTROLLER2.
In this class in the method DO_REQUEST ( for example ) i try to get the instance of the class
parent ( and i got it! ) using this syntax:
  data: Parent type ref to IF_BSP_DISPATCHER,   " type take from attribute M_PARENT of the class
Parent = ME->M_PARENT.
In debug i see that 'Parent'  get rightly the class parent instance but than i want do this:
(i want get the sub controller of the main contoller 'parent', in debug i can see everything fine)
   SubController = Parent->GET_ATTRIBUTE(LEFT_CONTROLLER).
But the compiler say that the class instance 'Parent' has no methods and no attribute.
i've try other syntax like:
    call METHOD Parent_>GET_ATTRIBUTE
        IMPORTING
     LEFT_CONTROLLER)
  call METHOD ME->M_PARENT->GET_CONTROLLER
   EXPORTING
     CONTROLLER_ID = 'search'
   IMPORTING
     CONTROLLER_INSTANCE = Parent2
No one work!
How can i do?
Here screnshot of that i see in debug mode, and that i want get:
http://img190.imageshack.us/i/1debugscreen.jpg/
http://img10.imageshack.us/i/2debugscreen.jpg/
Thanks in advance,
Davide
Repaly
Hi Pawan,
classes ref to CL_BSP_CONTROLLER2 like my controller class, have an attribute
M_PARENT type IF_BSP_DISPATCHER.
If the class is a subclass of an main class it has the M_PARENT attribute containing the instance of the parent class,
i can see in debug mode ( here example: http://img40.imageshack.us/img40/1648/3debugscreen.jpg )
i can get this attribute:
  data: Parent type ref to IF_BSP_DISPATCHER,   " type take from attribute M_PARENT of the class
Parent = ME->M_PARENT.
but  the interface IF_BSP_DISPATCHER has no attribute and no method defined, and if i declare 'Parent' as type ref to
CL_BSP_CONTROLLER2 the compiler return error
      <=>      "The type of "PARENT" cannot be converted to the type of "ME->M_PARENT". "
Davide
Read More: The other 8 answers