Skip to Content

If you wish to access the View Controller from methods on the Component Controller of a Web Dynpro component, you can do this very easily following the steps below:

Suppose we have a view called V_MAIN and a context node on that view called NODE_1.

/wp-content/uploads/2016/05/2016_05_30_19_08_39_964148.png

1) Create a global attribute GO_V_MAIN_CTRL of type IF_WD_VIEW_CONTROLLER in Component Controller’s attributes tab;

/wp-content/uploads/2016/05/2016_05_30_19_11_22_964128.png

2) Get the reference of View Controller in WDDOINIT method of view V_MAIN as below:

          wd_comp_controller->go_v_main_ctrl ?= wd_this->wd_get_api( ).

/wp-content/uploads/2016/05/2016_05_30_19_09_28_964129.png

Now, you can access the View Controller in any Component Controller method. As an example, you can access the View Context Node as below:

   DATA lo_context          TYPE REF TO if_wd_context.

   DATA lo_root_node      TYPE REF TO if_wd_context_node.

   DATA lo_child_node     TYPE REF TO if_wd_context_node.

 

   lo_context = wd_this->go_v_main_ctrl->get_context( ).

” get root node

   lo_root_node = lo_context->root_node.

” get child node

   lo_child_node = lo_root_node->get_child_node( name = ‘NODE_1’ ).



You can read more about other methods accessible by the IF_WD_VIEW_CONTROLLER here: IF_WD_VIEW_CONTROLLER – Web Dynpro for ABAP – SAP Library


Hope that helps!


Regards,

Felipe

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply