on 01-10-2012 4:11 AM
Hi,
I have a requirement where i need a instance of view controller class(impl) in custom controller class. When i am trying to create an instance attribute of impl class in cuco and trying to use in one of the cuco methods then it is not getting initialized. Let me know how to do achieve this.
Thanks a lot.
Regards,
Lisha
Hi Lisa,
You can try the following to get instance of view controller (IMPL) class in a custom controller. This needs to be done inside the method of a custom controller where you want the instance of view controller class.
1. Define an instance variable with Type Ref To <your impl class>
2. Define lr_window Type Ref To CL_BSP_WD_WINDOW.
3. use the attribute view_manager to get the window controller
lr_window = me->view_manager->get_window_controller( ).
4. view_controller_instance ?= lr_window->get_subcontroller_by_viewname( 'view_name').
here view_name would the name of view for which instance is required.
Regards
Ajay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I have tried below code but stil lr_impl is initial.
DATA: lr_impl TYPE REF TO ZL_ZTT_FR_CAP_IMPL,
lr_window TYPE REF TO cl_bsp_wd_window.
TRY .
lr_window = me->view_manager->get_window_controller( ).
lr_impl ?= lr_window->get_subcontroller_by_viewname( 'ZTT_FR/CAP').
CATCH cx_root.
ENDTRY.Thanks,
Lisha
Hi Lisha,
This would be because the corresponding view is in viewset which in turn is in the window.
In that case you will have to drill down the viewset and then get the view.
Sample code :
DATA:
lr_window TYPE REF TO cl_bsp_wd_window,
lr_viewset TYPE REF TO cl_bsp_wd_view_controller,
lr_bpexcp_view TYPE REF TO CL_BP_EXCEP_BPEXCPTNRESUL_IMPL.
lr_window ?= me->get_subcontroller_by_viewname( 'BPExceptionSearch.MainWindow' ).
if lr_window IS BOUND.
lr_viewset ?= lr_window->get_subcontroller_by_viewname( 'BP_EXCEPTION/BPExcptnSearchViewSet' ).
if lr_viewset IS BOUND.
lr_bpexcp_view ?= lr_viewset->get_subcontroller_by_viewname( 'BP_EXCEPTION/BPExcptnResult' ).
if lr_bpexcp_view IS BOUND.
TRY.
lr_bpexcp_view->GV_IS_NEW_CONTRACT = ABAP_TRUE. "#EC NOTEXT
CATCH cx_sy_dyn_call_error.
RETURN.
ENDTRY.
endif.
endif.
endif.Regards
Leon
Edited by: Leon Limson on Jan 10, 2012 4:54 PM
Hi
I have a similar requirement. my view is in an Overview page which is with in the Window. So I followed the same process as given. I have the instance of the main window but lr_ovp remains null.
lr_window ?= me->m_parent.
IF lr_window IS BOUND.
lr_ovp ?= lr_window->get_subcontroller_by_viewname( 'ZPDA_CLOSE/ZPDACloseOVP' ).
IF lr_ovp IS BOUND.
lr_custidview ?= lr_window->get_subcontroller_by_viewname( 'ZPDA_CLOSE/ZCustId' ).
Please help.
PS:This is a total custom component.
Hi,
You can use this syntax,
lr_view ?= get_subcontroller_by_viewname( 'BP_HEAD/BPHEADOverview' )..
Here Lr_view should be type ref to the view controller class.
'BP_HEAD/BPHEADOverview' is the view name
Regards ,
Ratna Rajesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.