Skip to Content
0
Former Member
Oct 15, 2005 at 05:18 AM

A problem in calling a subcontroller

33 Views

I try to use the model class and call a subcontroller class to display data in another view by using the following code.

<b>In the do_init of main controller</b>

* Create the model of this class
l_model = create_model( model_id = c_model_id
class_name = lc_class_name ).

* Create sub controller
l_controller ?= create_controller(
                      controller_name = lc_control_name
                      controller_id   = c_subcontrol_id ).
controller_set_active( controller_id = c_subcontrol_id
                       active        = 0 ).
l_controller->set_model( model_id       = c_model_id
                         model_instance = l_model ).

<b>In the dispatch_input( ) of main subcontroller</b>

main_view = create_view( view_name = 'main.htm' ).

l_model ?= get_model( c_model_id ).

<i>*To separate tasks between calling a view and calling *a subcontroller, I have to have a flag, current_event, *to check whether the coming event is search. This flag *is set at the method 'do_handle_event'</i>

if current_event eq lc_search.
   l_subcontrol ?= get_controller( 
                      controller_id =   c_subcontrol_id ).
   controller_set_active( controller_id = c_subcontrol_id
                          active        = 1 ).
   call_controller( l_subcontrol ).
   clear current_event.
elseif current_event is initial.
   call_view( main_view ).
endif.

In <b>the do_request of my subcontroller class</b>, I call the view of the subroutine.

<b>dispatch_input( ).</b>
l_model ?= get_model( 'mm' ).

stock_view = create_view( view_name = 'stock.htm' ).
stock_view->set_attribute(
          name = 't_display' value = l_model->t_display ).
stock_view->set_attribute( name = 'ITERATOR' value = me ).
stock_view->set_attribute( name  = 'show_popup' 
                           value = show_popup ).
call_view( stock_view ).

After any event occurs in this view of subroutine, I catch this event at <b>the method do_handle_evnt</b>.

if htmlb_event is bound.

   case htmlb_event->server_event.
     when 'onSelect'.

       CLASS CL_HTMLB_MANAGER DEFINITION LOAD.

       tv ?= cl_htmlb_manager=>get_data(
                               request = request
                               name = 'tableView'
                               id = 'stock_tv_display' ).
       if tv is not initial.
          table_event = tv->data.
          row_index = table_event->row_index.
          if row_index is not initial.
             show_popup = abap_true.
          endif.
       endif.

     when others.
   endcase.
endif.

After the program run through this method, it goes back to the do_request of the parent controller, main.do without passing the do_request of subcontroller. This is my problem. I don't want to call the parent controller again. And, my application has already been stateful. Is there any way to prevent it? Please give me some suggestions to solve this problem.