Get context node from view controller

Problem: you want to get the controller of a view and then get a context node from the controller.

Solution: assuming that both controller and context node are not accessible direclty you can do it by writing this small peace of ABAP code.

DATA:
  lo_model type ref to cl_bsp_model,
  lo_ctrl type ref to cl_bsp_wd_view_controller.
 
lo_ctrl = get_subcontroller_by_viewname( 'UsageName.ComponentName/WindowName' ).
if lo_ctrl is bound.
  lo_model = lo_ctrl->get_model( 'ModelName' ).
ENDIF.
DATA:
  lo_model type ref to cl_bsp_model,
  lo_ctrl type ref to cl_bsp_wd_view_controller.

lo_ctrl = get_subcontroller_by_viewname( 'UsageName.ComponentName/WindowName' ).
if lo_ctrl is bound.
  lo_model = lo_ctrl->get_model( 'ModelName' ).
ENDIF.

Komentowanie jest zakończone.