Skip to Content

Access Component Controller or Custom Controller in a context node class-2

There are two ways to access Component Controller or Custom Controller in a context node class.


1) In the View Controller’s Implementation class (ZL_XXXXX_IMPL) create a public instance attribute of type Component Controller’s IMPL class (ZL_XXXX_BSPWDCOMPONEN_IMPL).

2) Redefine the method WD_CREATE_CONTEXT of View Controller’s Implementation class 

   (ZL_XXXXX_IMPL) and add the below line of code.


   GV_COMP_CNTRL ?= me->comp_controller.

3) In the Context Node Class (CNXX), create a public instance variable gv_owner of type view controller’s implementation class (ZL_XXXXX_IMPL).

4) Redefine the method IF_BSP_MODEL~INIT of the Context Node Class (CNXX)

        method IF_BSP_MODEL~INIT.



      ID = id

      OWNER = owner.

  gv_owner ?= owner.


5) I will access the component controller in the method ON_NEW_FOCUS of the Context Node Class (CNXX)


lr_window TYPE REF TO cl_XXXXX_window_impl, ” Window Impl Class

lr_comp   TYPE REF TO zl_XXXXX_bspwdcomponen_impl, ” Component Controller Impl class

lr_access TYPE REF TO if_bol_bo_property_access,

lr_vc     TYPE REF TO zl_XXXXX_impl. ” View Controller Impl class

lr_vc      ?= gv_owner.

lr_window  ?= lv_vc->get_window( ).

lr_comp    ?= lr_window->m_parent.

lr_access  ?= lr_comp->ztyped_context->gvproduct->collection_wrapper->get_current( ).

Approach-2: In my previous blog i explained this.

You must be Logged on to comment or reply to a post.
  • Solution 3 (easier):

    1. In ZL_XXXXX_IMPL, create a public "GET_COMP_CONTROLLER" method with a "ro_comp_controller" return parameter typed as ZL_XXXX_BSPWDCOMPONEN_IMPL and add the below line of code:

       ro_comp_controller ?= me->comp_controller.

    2. In the Context Node Class (CNXX), get the component conrtoller this way:

      DATA: lo_controller           TYPE REF TO zl_xxxxx_impl,

                 lo_comp_controller TYPE REF TO zl_xxxxx_bspwdcomponen_impl.

      lo_controller ?= me->controller.

      lo_comp_controller = lo_controller->get_comp_controller( ).

    No need to create any attribute, no need to add code in init or wd_create_context methods.