That is not the proper way of doing it. You should implement the following methods in your overview page view controller class
-
DETACH_STATIC_OVW_VIEWS
-
REATTACH_STATIC_OVW_VIEWS
You may refer the methods in the class CL_PROD_PHA_PRODPHARMAEXT_IMPL. This is the case to dynamically add/remove views once the page is loaded.
But incase, if you know the condition even before the page is loaded, you should create to different configurations in the overview page each with one of the 2 views you have mentioned, and in the DO_CONFIG_DETERMINATION method, you can determinne which configuration to be loaded based on the condition.
-
Assign both views to this viewarea in Runtime Repository. Make on of it as a default.
Then in view conroller (_IMPL class) of you viewset in DO_PREPARE_OUTPUT make the following:
-
DATA: lt_children TYPE tbsp_wd_rep_views.
-
DATA: lr_rview TYPE REF TO cl_bsp_wd_rep_view.
-
DATA: lv_desired_viewname TYPE string.
-
****
-
* here should be some logic to fill in lv_desired_viewname according to your needs
-
***** lt_children = me->rep_view->get_all_children( iv_viewarea = 'ViewAreaA' ). "put your viewarea name here instead of ViewAreaA
-
LOOP AT lt_children INTO lr_rview.
-
IF lr_rview->get_name( ) CS lv_desired_viewname. "here you're looking for desired view
-
me->bind_view( rep_view = lr_rview viewarea = 'ViewAreaA' ). "put your viewarea name here instead of ViewAreaA
-
EXIT.
-
ENDIF.
-
ENDLOOP .
DATA: lt_children TYPE tbsp_wd_rep_views.
DATA: lr_rview TYPE REF TO cl_bsp_wd_rep_view.
DATA: lv_desired_viewname TYPE string.
****
* here should be some logic to fill in lv_desired_viewname according to your needs
***** lt_children = me->rep_view->get_all_children( iv_viewarea = 'ViewAreaA' ). "put your viewarea name here instead of ViewAreaA
LOOP AT lt_children INTO lr_rview.
IF lr_rview->get_name( ) CS lv_desired_viewname. "here you're looking for desired view
me->bind_view( rep_view = lr_rview viewarea = 'ViewAreaA' ). "put your viewarea name here instead of ViewAreaA
EXIT.
ENDIF.
ENDLOOP .