Skip to Content
author's profile photo Former Member
Former Member

Have a problem in calling a subcontroller

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</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 do_request</b>

controller_set_active( controller_id = c_subcontrol_id

active = 1 ).

call_controller( l_subcontrol ).

clear current_event.

At the view of subcontroller, after any event occurs, the parent controller is triggered again. Why? How can I solve this problem?

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Oct 13, 2005 at 05:43 AM

    hi

    In the event handling of subcontroller first your main controller is called , from there onwards event handling dispatched to subcontrollers.

    What u have to do is call <b>dispatch_input()</b> method in your main controller <b>do_request()</b> method.

    One more thing is that Your Application must be stateful to handle the events in subcontroller.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 13, 2005 at 06:28 AM

    I have already called the dispatch_input in the do_request of both parent controller (main.do) and subcontroller. And, my application is ticked to be stateful. But, the result is still the same.

    In do_request of main.do

    dispatch_input( ).
      main_view =
            create_view( view_name = 'main.htm' ).
      l_model ?= get_model( c_model_id ).
    
    
    
      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.
      else.
        call_view( main_view ).
      endif.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Shiva Suvarna

      I do appreciate your immediate reponse. However, there may be some misunderstanding. Of cource, I put the checking coming event in the do_handel_event. The details of my application is shown below.

      <b>In the do_init method</b>, all source code is the same that I posted. It has creating a model class and then a subcontroller class.

      <b>In the do_request method</b>, I have a code like this.

      <b>dispatch_input( ).</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, <b>current_event</b>, to check whether the coming event is search. This flag is set at the method <b>'do_handle_event'</b></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 the do_request of my subcontroller class, I call the view of the subroutine.

      dispatch_input( ).

      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 the method do_handle_evnt.

      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. 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. I sincerely appologize if I couldn't catch what you said. But, please give me some suggestions to solve this problem.

      Message was edited by: Amateur willbeProfessional

      Message was edited by: Amateur willbeProfessional

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.