Hello Experts-
I had a BSP-MVC related question.
If a master controller (1.do) creates and calls a view (1.htm) then how can I access one of the attributes of the master controller (1.do) from one of its sub-controllers (1a.do and 1b.do)?
Its easy to access attributes of sub-controllers because you can get an instance of the sub-controller from any other controller by referencing to it through the 'm_parent' object (and using the get_controller method with a reference to the controller/component id of the sub-controller). Its relatively simple to identify them (sub-controllers) and their attributes.
However, since the master controller (1.do) is the point of access of the application and is called directly from the web-browser, there is no location to specify its controller id.
So, my question is, where do I assign a controller/component id to my master controller? Or, how do I refer to an attribute of the master controller if I am unable to assign a controller/component ID to it?
Thanks,
- Vik.
Hi,
"m_parent" IS the handle to your master controller (if you are referring it from a sub-controller).
So, all you have to do is, assign it (with Cast) to the controller class and start accessing the attributes.
As simple easy as that 😉
data: master_controller type ref to ZCL_YOUR_MASTER_CLASS.
master_controller ?= m_parent.
(and, start accessing the attributes)
a = master_controller->attribute1.
b = master_controller->attribute2.
...
Regards,
Venky Varadadesigan
SAP NetWeaver consulting.
Add a comment