Reference to Custome Controller from View controller

Hi all,
I have created a custom controller and inside that i have a method. i need to execute that method from a view controller, similar to executing a method in the component controller. to execute a method in the component controller i use the WD_COMP_CONTROLLER attribute to refer to the component controller. similarly how to i refer my custom controller from the view, or is there any other way? it would be great if someone can help me with this.
Malinda

hi,
Lets say view1 has the event ONACTIONNAVIGATE and you want to call a method 'start_navigation' in the custom controller named 'navigation'.
Use the following code.
METHOD onactionnavigate .
  DATA lo_navigation_controller TYPE REF TO ig_navigation.
  lo_navigation_controller = wd_this->get_navigation_ctr( ).
  CASE navigation_type.
    WHEN 'BACKWARD'.
      lo_navigation_controller->start_navigation( if_fitv_fpm_api=>gc_navigate_backward ).
    WHEN 'FORWARD'.
      lo_navigation_controller->start_navigation( if_fitv_fpm_api=>gc_navigate_forward ).
  ENDCASE.
ENDMETHOD.
Thanks,
Rajkumar.S

Similar Messages

  • How to get a reference for custom controller

    Hi All,
         I am working with the custom controller but i dont know how to call the functionality of custom controller into a view controller.For accessing component controller functionality we have a attribute wd_comp_controller in view controller.Like this how to get a refernce for the custom controller.
    Thanks in Advance.

    hi,
    Lets say view1 has the event ONACTIONNAVIGATE and you want to call a method 'start_navigation' in the custom controller named 'navigation'.
    Use the following code.
    METHOD onactionnavigate .
    DATA lo_navigation_controller TYPE REF TO ig_navigation.
    lo_navigation_controller = wd_this->get_navigation_ctr( ).
    CASE navigation_type.
    WHEN 'BACKWARD'.
    lo_navigation_controller->start_navigation( if_fitv_fpm_api=>gc_navigate_backward ).
    WHEN 'FORWARD'.
    lo_navigation_controller->start_navigation( if_fitv_fpm_api=>gc_navigate_forward ).
    ENDCASE.
    ENDMETHOD.
    Thanks,
    Rajkumar.S

  • How to get the reference of the View controller in from Custome controller

    Hi friends,
    From one of the Custome controllers in my Component,I am raising a popup based on conditions.
    I want to subscribe to popup buttons.
    Following is the code that I have written.
    IF LT_RECEIPTS_T[] IS not INITIAL.
        data lo_window_manager type ref to if_wd_window_manager.
        data lo_api_component  type ref to if_wd_component.
        data lo_window         type ref to if_wd_window.
    *BREAK-POINT.
        lo_api_component  = wd_comp_controller->wd_get_api( ).
        lo_window_manager = lo_api_component->get_window_manager( ).
        lo_window         = lo_window_manager->create_window(
                           window_name            = 'W_PERSONALCARDPOPUP'
                           message_display_mode   = if_wd_window=>co_msg_display_mode_selected
                           button_kind            = if_wd_window=>co_buttons_okcancel
                           message_type           = if_wd_window=>co_msg_type_none ).
        lo_window->open( ).
        DATA: view_controller TYPE REF TO if_wd_view_controller.
        view_controller = wd_this->wd_get_api( ).
        CALL METHOD lo_window->subscribe_to_button_event
          EXPORTING
            button      = if_wd_window=>co_button_ok
            action_name = 'OK'
            action_view = view_controller.
    as I am In Custome controller,wd_get_api is returing of type if_wd_controller,but the subscribe_to_button_event
    requires action_view of data type if_wd_view_controller.
    but,my problem is that I can keep the view only Custome controller.
    when I pass the 'VIEW_CONTROLLER' variable to method subscribe_to_button_event,I am getting the error  as type missmatch.
    Please suggest how I can rectify this error.
    Regards,
    Xavier.P

    Hi Xavier,
    You try this
    1. Define an attribute in your custom controller to hold your popup window reference for e.g lr_popup of type if_wd_window
    2. Store the popup window reference in lr_popup when calling your popup
    lo_api_component = wd_comp_controller->wd_get_api( ).
              lo_window_manager = lo_api_component->get_window_manager( ).
              wd_this->lr_popup = lo_window_manager->create_window(
                              window_name = 'W_PERSONALCARDPOPUP'
                              message_display_mode = if_wd_window=>co_msg_display_mode_selected
                              button_kind = if_wd_window=>co_buttons_okcancel
                              message_type = if_wd_window=>co_msg_type_none ).
             wd_this->lr_popup->open( ).
    3. Define the custom controller usage in the properties of your popup view
    4. In WDDOINIT of your popup view write the following
    DATA lr_custom_controller TYPE REF TO ig_<Custom Controller>.
            lr_custom_controller = wd_this->get_<Custom Controller>_ctr( );
            lr_custom_controller->lr_popup->subscribe_to_button_event(
         button = if_wd_window=>co_button_ok
         action_name = 'OK'
         action_view = wd_this->wd_get_api( ) ).
    5. Define the event handler for OK in your popup view
    Best Regards,
    Loveline

  • How to call Custom or Component Controller methods from View Controller

    Hy Guys,
    how do I call Custom Controller or Component controller methods from a View or Context Controlller?
    thanks in advance
    Jürgen

    Hi Juergen
    Yes it is possible, pls follow the below approach to access the component controller in context node class
    1) since the standard component controller class is protect variable , declare a variable of type component controller in your controller class.
    say for example the public variable you declared is  g_comp_controller
    2)  now redefine the controller class method WD_CREATE_CONTEXT  and add the below lines of code
       g_comp_controller ?= me->comp_controller.
    3) go to context node class  (CNXX)  there declare the varaible which of type controller class (IMPL)  as public variable, for example g_owner
    4) redefine the method  IF_BSP_MODEL~INIT  and write the below code
         CALL METHOD super->if_bsp_model~init
        EXPORTING
          id    = id
          owner = owner.
      g_owner ?= owner.
    5) now the variable   g_owner  that is declared in  (CNXX)   contains reference to your controller class
    6) in  on_new_focus  method access your component controller in the below manner and access the entities also.
    DATA: lv_owner                    TYPE REF TO xxxxx_impl,  " Implementation class
                 lr_comp_cont                TYPE REF TO xxxx_bspwdcomponen_impl, " component controller class
                 lv_entity type ref to cl_crm_bol_entity.
    lv_owner ?= g_owner.
    lr_comp_cont    ?= lv_owner->g_comp_controller.
    IF lr_comp_cont IS BOUND.
       lv_entity ?= lr_comp_cont->typed_context->mdfcampaign->collection_wrapper->get_current( ).
    now lv_entity contains the value of component controller context node.
    Thanks & Regards
    Raj
    Edited by: bmsraj on Sep 27, 2011 3:28 PM

  • How to call a custom controller method from view

    Hi,
    I ve created a simple web service and consumed it in a model. Mapped the input & output parameters to custom controller context which in turn mapped to component controller's context which in turn to view's contexts.
    How to call a custom controller method from view?
    Please explain the syntax.
    Regards,
    Manoj.

    Hi Patralekha,
    Give some idea for the below scenario:
    I ve created a simple web service and consumed it in a model. What I did was
    1) for the input parameters, mapped the node from view->custom controller->model
    2)for the output parameter, mapping from model->custom controller->view.
    It works fine.
    But I don't want to access model nodes directly, rather I want to set the input param in somewhere else (like custom controller) before calling the appropriate method, same for the response also.
    Share me your thoughts.
    Regards,
    Manoj.

  • Passing field values from View Controller to Custom Controller

    Hi Experts,
    I am working on a customer requirment in which customer want to see the values of field from one view in another view. The Context node & Context node attribute are the same in both the views.
    I am aware that we need to pass the field values from view controller to custom controller in order to see the field in the subsequent view. I would like to kow how i can achieve that technically?
    Kindly let me your valueable suggesions.
    Best Regards,
    Prabahar

    Hi Carsten,
    Thank you for the detailed feedback.
    I want the fields ID_TYPE & ID_TYPE_DESCRIPTION from IUICMD/SearchAccount to be available in IUICMD/DetailAccount. I have created a context node u201CSEARCHu201D in view IUICMD/DetailAccount. I have created the context node with out choosing u201CCreate with Instanceu201D.  This Context node (SEARCH) is already available in IUICMD/SearchAccount as part of the standard.
    Below given is contents of the Method CREATE_SEARCH of my context class ZL_IUICMD_DETAILACCOUNT_CTXT of view IUICMD/DetailAccount, which is created by the Wizard during enhancement.
    method CREATE_SEARCH.
        DATA:
          model        TYPE REF TO if_bsp_model,
          coll_wrapper TYPE REF TO cl_bsp_wd_collection_wrapper,
          entity       TYPE REF TO cl_crm_bol_entity,    "#EC *
          entity_col   TYPE REF TO if_bol_entity_col.    "#EC *
        model = owner->create_model(
            class_name     = 'ZL_IUICMD_DETAILACCOUNT_CN00'
            model_id       = 'SEARCH' ). "#EC NOTEXT
        SEARCH ?= model.
        CLEAR model.
    bind to custom controller
      owner->do_context_node_binding(
               iv_controller_type = CL_BSP_WD_CONTROLLER=>CO_TYPE_CUSTOM
               iv_name = 'IUICMD/CuCoMD' "#EC NOTEXT
               iv_target_node_name = 'BUILHEADERSEARCH'
               iv_node_2_bind = SEARCH ).
    endmethod.
    I have enhanced the Custom Controller. Now it have new implementation class u201CZL_IUICMD_CUCOMD_IMPLu201D
    Let me know where I am doing mistake
    Thanks in advance
    Best Regards,
    Prabahar
    Edited by: Prabahar Raju on Sep 2, 2009 10:47 AM
    Edited by: Prabahar Raju on Sep 2, 2009 10:52 AM

  • Method in custom controller not getting called from view

    Hi experts,
    I have a very strange problem. My web dynpro application works fine on the development portal. i am in the process of deploying to the production portal there is no issue it deploys perfectly without any problems. However i have noticed that some methods in my custom controlller which are called from the view do not run. there is no error message or anything data just doesnt get picked because the execute function which fills the context are in the custom controller methods.
    For some reason the method in the custom controller does not get called even though i'm calling it for the view. I have this problem with two methods. the other methods work without any issue.
    Now i overwrote what i have on production at the moment so am stuck and in need for a solution.
    I have tried undeplying, restarting and re-deploying to no avail. what could be wrong?
    thanks and regards,
    dilanke

    Deal all
    This is the code. basically im calling it from the plug on the detail screen.
    This is the method that doesnt get called anymore.
    wdThis.wdGetGetPurchaseOrderCustController().getPODetail();
    The reportSuccess() works fine.
    regards,
    Dilanke
      public void onPlugFromListView(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onPlugFromListView(ServerEvent)
         try
             String po = wdThis.wdGetGetPurchaseOrderCustController().wdGetContext().currentContextElement().getPO_Id();
              wdContext.currentZGETPODETAILS_INPUTElement().setI_Ebeln(po);
              wdThis.wdGetGetPurchaseOrderCustController().getPODetail();
              wdComponentAPI.getMessageManager().reportSuccess(po);
              String fileName = "F://XML_Downloads//" + po + ".xml";
              IWDResource resource = WDResourceFactory.createResource(new FileInputStream(new File(fileName)),fileName,WDWebResourceType.XML,true);
              wdContext.currentContextElement().setXml_Resource(resource);
         catch(Exception e)
              e.printStackTrace();     
        //@@end

  • Calling a view method from Custom Controller

    Hi,
    I would like to know is there any way to call a method in a view from the custom controller?
    urgent. Thank you very much

    Hi Jo,
    again, no, this is not possible, since you 1. can't declare a usage of any View for a custom controller and 2. you can't fire an Outbound plug from a controller which doesn't "belong to" a View or Interface View.
    Think different It's possible the other way around:
    1. Declare an event, maybe "viewTrigger" for the custom controller CC.
    2. Add CC to the "Required Controllers" of the View.
    3. Declare an Event Handler to the Methods of the View, maybe "handleViewTrigger". The Event source is the created event in CC.
    4. Firing the event in CC by calling wdThis.wdFireEventViewTrigger(); in CC's implementation will invoke the handleXXX method in the View, if and only if the View is visible.
    Hope that helps.
    Regards
    Stefan

  • How to call a custom controller method in a view

    Hi ,
    I am getting the partner no in the custom controller method . I want  to call that method in the view.How is it possible......?

    Hi Masood,
    now i dont want cross compnent navigation ....
    Requirement : Account Identification number in ZVIEW
    My component is  CRMCMP_BPIDENT
    In the custom controller   CRMCMP_BPIDENT/CuCoBuPa  under context node   SEARCHCUSTOMER
    the attribute struct.partner is available 
    in this component  im navigating from  
    CRMCMP_BPIDENT/ObjectCompVs   to   ZCRMCMP_BPIDENT/ZProducts 
    in the layout of   ZCRMCMP_BPIDENT/ZProducts
    TRY .
    lr_cuco ?= controller->get_custom_controller( 'CRMCMP_BPIDENT/CuCoBuPa' ).
    CATCH cx_sy_move_cast_error.
    RETURN.
    ENDTRY.
    check lr_cuco is bound.
    lr_entity ?= lr_cuco->typed_context->SEARCHCUSTOMER->collection_wrapper->get_current( ).
    check lr_entity is bound.
    lv_account_name = lr_entity->get_property_as_string( iv_attr_name = 'BP_NUMBER' ).
    this code is written to get the account identification number but still the same problem
    lr_entity not getting populated .......
    i checked  IF_BSP_WD_HISTORY_STATE_DESCR~IS_RESTORABLE 
    hr rv_result is set to x.....
    any  suggestions....
    Regards,
    Sijo...

  • Do I need to use a custom controller & view set

    Good Day,
    Please excuse the long question.
    I am in the process of creating a new BSP application.  In a nut shell, my application is going to accept a bunch of data in the URL and pass the data to an external system.  Depending on what is returned from the external system, it will prompt the user to either supplement the data or to confirm what the external system has sent back. 
    I would like to have all of the business logic that communicates with the external system and decides what type of user interaction to be located in one central class.  I was thinking that I could have a custom controller that is resident for the life of the application.  It would call the external system and navigate to other views depending on what is required.  When the user responds, the response would go to the custom controller and be sent to the external system.  So, my first question is does this sound reasonable?  For my second question, is it possible to have a view associated with the custom controller.  If so, I can use it for the confirmation "screen".
    While looking at the Web IC cookbook, I ran accross the section on view sets.  Are there pros and cons to using a vew set for an application like this?  I expect the browser window to contain one view at a time and it kind of seems like view sets may intended more for where there are several views displayed within the browser and the view set allows you to change only one.  Is that true?
    Thank you very much for any insight you can offer.  I promise to award points for helpful responses.
    Thanks and kind regards,
    John

    Hi John,
    My suggestions would be to use a model class for the business logic and call to the external system.  The controller would only be for eventing and determining what view to call.  I would create a parameter called view_name on the controller and toogle this between your views depending on what returns from your model methods.  As a personal preference I would pass the 'bunch of data' in the form rather than the URL.  Validate it in a model method before sending it to the external system.  I tend to use URL querystrings for small stuff rather than large application data.  Also what would happen to the application if someone saves your URL as a favorite and launchs the app.
    Those are my thoughts hope it was helpful.
    Regards
    Matt

  • Diff between Component controller,Custome controller and  View controller

    hi,
        Can any body tell me the following details,
    1.difference between the Component controller,Custome controller and  View controller in WD-ABAP.?
    2.what is Lead Selection?   
    Regards,
    Ravi

    Hi Ravi.
    The component controller is visbile to all views in a component. So all context nodes and methods you create here can be accessed from all views in the component. This way you can share data between the views by mapping context nodes or thru method calls. You can also mark methods and nodes as interface so that they are acessable from other components that define component usages to this cmponent.
    Custom controller is quiet similar to the component controller. You can define it if you want to group some views with a custom controller for a certain functionality.
    If you want to access a custom controller in a view you have to define the usage first on the properties tab of the view.
    A view controller is only visible in the view itself. So all methods or context nodes you define here are only accesable by the current view.
    The lead selection is in most cases the current selected element in a context node. The lead selection is used by many UI elements to determine which element has to be shown (e.g drop down).
    If you have a table with single selection the current selected table row is the lead selection element of the bound context node.
    SO you can get the lead selection element easily in any mthod by calling context_node->get_element( ).
    Hope this clears your questions.
    Cheers,
    Sascha

  • Accessing Custom Controller from setter and Getter methods

    Hi Gurus
    How can we access the custom controller from setter and getter methods,is there any way to do that.
    Thanks & Regards
    Rajasekhar

    Hi Steve.
    Thanks very much for valuable information,  the main controller class is getting tracked in mo_owner which is declared as  CL_BSP_WD_VIEW_CONTROLLER, and I'm getting the reference through
    mo_owner ?= owner. (since mo_owner = owner is not getting converted of type mo_owner ). After doing this on whatever the contexnode class (say zl_xxxx_xxx_cnxx) the corressponding context node values are getting turned as  <#ERROR IN METADATA.
    I mean when I'm checking the configuration in bsp_wd_cmpwb configuration tab -> Available Fields->Enlarge the contex node->BTSTATUS (say for Example) there the values are showing as <#ERROR IN METADATA , After executing the above procedure
    I cross checked several times before and after redefining the context node method IF_BSP_MODEL~INIT, before redefining this method UI is working fine, after redefintion UI is throwing below error .
    Exception Details
    CX_SY_REF_IS_INITIAL - Dereferencing of the NULL reference
    Method: CL_BSP_MODEL=>IF_BSP_MODEL_BINDING~IS_ATTRIBUTE_VALID
    Source Text Row: 13
    Thanks & Regards
    Rajasekhar

  • How to Call BAPI From the Custom Controller

    Hi
    I developed frist WD Application Using RFC Adapter.
    i did the following steps
    1. created the project
    2. created the model.
    3. created the customer controller and mapped the model of the controller to the model.
    4. mapped controller context to the views
    5. created one action in the start view
    6. created one method in the customer controller.
    so please let me know the lines of code to call BAPI using RFC.
    and  how to pass input valus to the bapi and how to execute the BAPI
    plese send the reply ASAP
    regards
    mmukesh

    Hi
    i did like this
    In  Start View OnActionSearch () method code
    public void onActionsearch (com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
           wdThis.wdGetTestCustControllerController().executeGetlistBapi();
    in CustomController Init method
    public void wdDoInit()
        Bapi_Flight_Getlist_Input input = new Bapi_Flight_Getlist_Input();
        wdContext.nodeBapi_FlightGetlist_Input().bind(input);
        input.setDestination_From(new Bapisfldst());
        input.setDestination_To(new Bapisfldst());
    In CUSTOMECONTROLLER executeGetlistBapi();
    METHOD
    public void executeGetlistBapi( )
        //@@begin executeGetlistBapi()
        try{
           wdContext.currentBapi_FlightGetlist_InputElement().modelObject().execute();
           wdContext.nodeOutput().invalidate();
        }catch(Exception ex){
           ex.printStackTrace();
    Then let me know what is wrong in this
    i did as per pdf
    please correct if there is any worng in this code.
    this is flight example .
    regards
    mmukesh

  • Call methods from view controller to another (enhanced) view controller!

    Dear All,
    Is it possible to use/call methods from view controller to another (enhanced) view controller? Iu2019ve created a view using enhancement in standard WD component. I would like to call one method from standard view controller in the enhanced view controller.
    Is it possible to include text symbols as enhancement in standard class?
    u2026Naddy

    Hi,
    If you have just enhanced an existing view then you can call the standard methods in one of the new methods which you will create as part of enhancement.
    If you have created a totally new view using enhancement framework option ( Create as Enhancement ) then in this new view you won't be able to use existing methods in other view as a view controller is private in nature. So all the view attributes, context nodes and methods are Private to that view only.
    Regarding text elements, I guess adding a new text element is just a table entry in text table and is therefore not recorded as enhancement.( Not very sure about this, need to double check )
    Regards
    Manas Dua

  • Calling methods in controller from View.

    Hi Experts,
    Can any one let me know or point to the document which explains how to call a userdefined method in component controller from view.
    Thanks,
    James

    You have to define a "controller usage" using the controller editor. Then the code generator will create an accessor "wdGet<ControllerName>Controller()" to the component controller which can be used to call its methods.
    See also this document:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0ba2c45-0518-2a10-73be-9b785e10aef1
    Armin

Maybe you are looking for

  • How to use rule and send the same email to multiple recipents

    Hi, My requirement is to send the workitem to the multiple recipents. one of my reiend suggest me to use the rule but i don't know how to use that . can any one of you suggest me how to use rule in workflow. Also i want to send the same email to mult

  • How to reference arrays dynamically?

    I have developed a sql query with a dynamic number of rows and columns. I know I can reference the rows by using a ' for i in 1..htmldb_application.g_f01(i) loop' and this is fine. I know that with a query with a standard number of columns you could

  • Trying to get a new iPod touch to where the old one was at

    So a year ago I purchased an iPod and along with it I bought the 2 yr extended Warranty. Well a couple of weeks ago the touch screen stopped working. I tried everything to get it to work again Recharge reset I even tried restoring and nothing fixed i

  • Communication channel alerts

    Hi, We have a ccms system.  I would like to know for a specific communication channel whther any alerts has been setup. I assume normally alerts would be generic across any communication channel errors. If yes, please guide where to check and the nec

  • Lightroom Gallery

    I am looking to publish portrait photographs on my studio website via Lightroom 2.5. Recently a customer asked me to password protect the gallery before posting onto the web to ensure family privacy. The facility is not currently (!) there. So how ca