Custom controller v Assistance Class

Hi
I have always used the assistance class to place all business logic.  I understand that this replaces the custom controller that is generally used for theis purpose in WDJ. Therefore, is the custom controller used much in WDA or is it largely redundant?
Cheers
Ian

>
Abhimanyu Lagishetti wrote:
> Hi Ian,
>
>  It is not largely redundant as such, i can see two main reasons
>
>  1.  Configuration Controller, entire FPM is based on this. you can control the configuration of the WDA using custom controller
>
>  2. Business Logic, which belong to only current WDA can be put in Custom Controller so that it is more readable, where as in Assistance class we can use it in other applications when working in a team
>
> in both the cases you are following MVC
>
> Abhi
1.  You are correct that configuration controllers are a useful feature of custom controllers; however FPM is not really based on this.  Custom Controllers/Configuration Controllers in your components are not a requirement of FPM.  In FPM your component implements a special Web Dynpro Component Interface.  The configuration of the FPM is done using component configuration of a standard SAP component.  Once again you can use Configuration Controllers in your FPM components like you would in any other component; but it is in no way a requirement to do so in order to use FPM.
2.  Technically it is possible to place business logic in the custom controller, but my personal suggestion would be to not do so.  The context and context bindings carry a performance penalty and should only be used data that is needed by the layouts.  You end up creating custom controllers with logic that is locked into the component and only uses the attributes/methods.  What you end up with is a less useful class.  That is why I feel that using a normal ABAP class (possibly an Assistance Class) is the perfered way to go.
I would add a third use: the service call wizards.  If you are going to use the wizards to generate calls to RFCs or other classes, it is often advisable to place this generated code into a custom controller (one of the wizard options). This is particularly useful if you are going to have more than one wizard call generated.  I guess you could make a case that this is the "business logic" that was being refered to in Item 2 above.  However I want would make the distinction that this is only the call to the business logic.

Similar Messages

  • Assistance class not instantiated in the component controller of an ABAP WD

    I have a very weird problem when trying to launch an ABAP webdynpro I get a short dump, looking into it the assitance class does not get instantiated properly so it falls over.  It used to work, but I don't think I have substantially changed anything with the assitance class just on the layout, although something must have changed.
    In the constructor of the component controller it trys to cast (I think that is the correct term)  the assistance class from the compoent controller as below, Me->f_Alter_Ego->assistance_class is initial so that fails, it then tries to create the assistance class and falls over on create object Me->f_Assist.
      try.
        Me->f_Assist ?= Me->f_Alter_Ego->assistance_class.
      catch cx_sy_move_cast_error.    "#EC NO_HANDLER
      endtry.
      if not Me->f_Assist is bound.
        create object Me->f_Assist.
      endif.
    Extract from the short dump below.
    What happened?
        Error in the ABAP Application Program
        The current ABAP program "/1BCWDY/4LYS0NWZ8L8ENKKA93YQ==CP" had to be
         terminated because it has
        come across a statement that unfortunately cannot be executed.
        The following syntax error occurred in program
         "ZCL_WD_USER_MAINT=============CP " in include
         "ZCL_WD_USER_MAINT=============CM004 " in
        line 7:
        "You can only use "class=>method" with static methods."
    Other ABAP web dynpros in our system are fine.
    I have tried the obvious stuff like removing the assitance class from the WD component and putting it back in again.
    There is obviously somehting I am missing can anyone point me in the right direction or has experienced this before?
    Thanks,
    Tim

    Thanks Thomas,
    I could not see the wood for the trees on that one, I had syntax checked the assitance class ZCL_WD_USER_MAINT, however, that error would have been raised at runtime.
    Anyway all sorted now.
    Cheers,
    Tim

  • Instance of IMPL class in custom controller

    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 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

  • Cannot locate custom controller class after applying OIE.K  patch.

    Hi,
    I am trying to search all the region level personalizations(on Update Allocations Page in iExpenses while creating Expense Reports) to find out where our custom controller class is being called(it was personalized at site level). But no luck until now.
    Nevertheless, we were able to locate our custom controller class in an instance where the OIE.K oracle patch was not applied. Seems like after applying this patch, the seeded region names are changed too. Our custom code also works but cannot figure out where our CO is being called.
    Any suggestions please?
    Thanks,
    Swati.

    Guys,
    Using "About the Page" link on UpdateExpenseAllocationsPG, I found SplitCriteriaTblCO controller class instead of UpdateKffCO class, that was extended to HumUpdateKffCO custom class.
    Our custom code is still intact even though we do not find our custom CO. Probably we have to look elsewhere to find it, no idea!.
    I just need to know how to remove our iExpense extension. In order to remove the iExpense extensions in the instance where the OIE.K was not applied, we just removed the personalization at site level, where the controller HumUpdateKffCO was called and that took care of it.
    --Swati.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Issue in Binding Custom controller to Component Controller

    Dear All,
    I have enhanced a standard component ERP_H.
    I created a custom controller with context nodes BTSTATUS, BTSTATUSH
    I enhanced the component controller with context node BTSTATUS, BTSTATUSH
    Now when i try to bind the custom controller to component controller using this code in the context class of my custom controller
    bind to component controller
      owner->do_context_node_binding(
               iv_controller_type = CL_BSP_WD_CONTROLLER=>CO_TYPE_COMPONENT
               iv_target_node_name = 'BTSTATUS'  " component controller context node
               iv_node_2_bind = BTStatus ).
    its not working since this context node in component controller is not the standard one but the custom added one.
    Am i missing something, or is there any way to bind customer context node in custom controller to customer context node in component controller.
    regards,
    pradeep

    Hi pradeep,
        Try the other way round go to the context class in the component controller and paste the following code in the
    create_contextnode( context node = name of the node to be linked).
    *owner->do_context_node_binding(
            iv_controller_type = cl_bsp_wd_controller=>co_type_custom   <-----linking from component to custom
            iv_target_node_name = 'BUILHEADER' "target node: component controller node
            iv_node_2_bind = BUILHEADER ). "source node: current node.
    See if this works.
    Thanks

  • 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

  • Custom controller iue in OOPS ALV

    Hi All,
    I have created a ALV report by OOPS. I have used custom controller. In my sytem the outpout creen are id different and in other system the output screen area is different. How to avoid this issue? I want the report output should be system independent and it should take complete screen area?
    Please help..
    Regards,
    Jeetu

    Hi Jeetu,
    You should not drag-drop & create a container in screen layout.
    Instead you need to declare docking container using class cl_gui_docking_container.
    Sample code below:
      CONSTANTS: lc_height TYPE i VALUE 1200.
      IF sy-batch IS INITIAL.
        CREATE OBJECT go_container
          EXPORTING
            repid                       = sy-repid
            dynnr                       = sy-dynnr
            side                        = 2             " Top
            extension                   = lc_height
            metric                      = 1             " Pixel
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
      ENDIF.
    Regards,
    Nisha Vengal.

  • 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

  • Custom controller - WEBDYNPRO

    My friends what is the use of custom controller at what situation we should use that.
    And if we declare custom controller will it be considered globally
    Edited by: VENKATESH MADANAGOPAL on Sep 30, 2008 7:33 AM

    Hi Venkatesh,
    Try going through the SAP documentation you will come across the desired information. The below lines are taken from 1 such source.
    Regards,
    Uday
    Custom controllers are optional controllers that must be defined by the developer. These controllers can be used to modularize the component content. For example, custom controllers can act as local controllers for some views, or they can be used to encapsulate the logic related to a certain model class (business logic).
    This allows you to reduce the content of the component controller by populating sub-functions.
    Custom controllers are optional. They have to be defined at design time and can be used to encapsulate sub-functions of the component controller. Multiple custom controllers can be defined in a component. Custom controllers are instantiated automatically by the Web Dynpro framework and the instantiation order is undefined; therefore, the coding in a custom controller should

  • Relavance of assistant class in Webdynpro ABAP.

    When we can create a object for a class in the attributes tab of the component controller and acess the methods of the class directly, why do we need a assistant class.??
    Moderator message : Search for available information, post the question in Web Dynpro forum, thread locked
    Edited by: Vinod Kumar on Dec 22, 2011 3:09 PM

    Hai,
           In webdynpro ABAP,we use to write all the coding part within the component itself but there is a provision with which we can write the necessary business logic outside the component that is in a class and we can use that class as the assistance class in the current component. It is same as model class.

  • 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

  • Abap error when using Web Dynpro assistance class

    Hello All,
    I created Web Dynpro component with assistance class.
    On the component controller I can see the attribute "WD_ASSIST".
    I also can use Goto  -> text symbols and create net text key.
    But when I tried to read the text:
    wd_assist->get_text( '001' ).
    There is abap error:
    Method get_text is unknown protected or private.
    I can see the method get_text inside my assistance class like this:
    IF_WD_COMPONENT_ASSISTANCE~GET_TEXT visibility - public.
    I think I missed something while creating the assistance class?
    Thanks in advanced for the help.
    Nir

    Your method call should be:
    wd_assist->IF_WD_COMPONENT_ASSISTANCE~get_text( '001' ).
    You have to supply the interface name or go into the class definition and create a public alias for that method.

  • Raising Exceptions and Assistance classes

    Hi everyone. I know that the WDA framwork will not let me declare a raising clause in the method signature. However, during checks in the component i usually declare some code like this which is not pretty:
    The methods below were declared in the view controller.
    *---this method is called from DOBEFOREACTION method
    METHOD validate_view_fields .
      DATA: l_returncode TYPE sysubrc.
      CALL METHOD validate_required_fields(
        IMPORTING
          e_returncode = l_returncode ).
      IF l_returncode <> 0.
        e_returncode = l_returncode.
      ENDIF.
    -more code down here-
    ENDMETHOD.
    I would like the framework to call a method and if something goes wrong I do not want to proceed further down the code or navigate. If I could declare exceptions I could handle this pretty easily.
    If assistance classes or model classes are the answer then would I be able to read the context from those classes? I've also read that passing references of the web dynpro controllers to the assistance class could produce some problems.
    What's the best way to check the view fields and to prevent going further with the subsequent code if an exception condition is found?
    Thanks! Generous points will be awarded!

    Hi Alexander,
    The best way to check the input fields and prevent the framework from calling further methods is this:
    Check the values in WDDOBEFOREACTION. In this method you can check the name of the action, if it is an action of the same view. Maybe you want to skip testing, if the user pressed the CANCEL button or something similar.
    Report the message as an error message attached to an attribute. Then the next methods (e.g. event handler) will not be called, and therefore no navigation will take place.
    If this does not work as described here, you should check your basis support package. It should be SP11 or higher.
    Ciao, Regina

  • Wat is  Assistance class in WD for Abap

    hi,
    Can any one gives perfect picture about  Asisstance class in Webdynpro abap.
    Thanks in advance.
    Best Regards,
    Kranthi.

    Assistance Class in WD is used for storing common reusable logic apart from component controller.
    It can also be used to store Text Symbols for displaying messages or lables for the WD application.
    Per WD session there will be one instance of assistance class ( if mentioned ) will be automatically instantiated and you can access it by wd_assist.
    It can also be used to store a reusable set of constants, public attributes, types etc.
    Assistance class has some standard methods like get_text to fetch text from text symbols.
    To craete an assistance class you have to create a normal class and then mention CL_WD_COMPONENT_ASSISTANCE as superclass. Then you can metion you class name in WD Component Header Details.
    To have a look of assistance class you can look at CL_WD_COMPONENT_ASSISTANCE class then navigate to all its Subclasses ( Assistance Class ). The methods will give you an idea of the usage.
    Hope this helps
    Regards
    manas Dua

  • Assistance Class

    Hi Experts,
    I know assistance class is being useful for passing the value throughout the components. I have two WDP components which is CompA and CompB. In CompA I have to key in a value in which it need to be used in the following components. When it goes to CompB, the value will be used to populate a table which is from database. So far I have created the assistance class with belows method:
    method GET_USER_PROFILE.
    SELECT * FROM PA0002
    INTO CORRESPONDING FIELDS OF TABLE LT_USER
    WHERE PERNR = USRID AND endda > sy-datum AND begda < sy-datum.
    endmethod.
    USRID is the Importing parameter while LT_USER is the exporting parameter which is a table.
    This method works well in CompA which is the table is created successfully. But the table is actually to be used in CompB. So how am I going to do that? Besides, I'm so confuse of using assistance class in WDP. It would be great if someone can clarify the usage of that. Thanks.
    Regards,
    YC
    Edited by: ycwong on Mar 12, 2011 11:23 AM

    Hi Bhaskaran,
    i used same assistance class for two components, however i have two different instances of assistant classes in two components and not able to share data, however as you said when i pass assistance class instance wd_assist to create component , i am able to share data
    comp A with assistance class AS
    comp B with assistance class AS
    assitance class with attribute "myattr"
    in component controller method wddoinit of comp A i have statement
    wd_assist->myattr = 'Comp A'.
    in the view controller method wddoinit of comp B i created component usage of A ( i have declared component usage of A in B )
    and then
    lv_string = wd_assist->myattr.
    lv_string is empty after this statement..
    what i felt is wd_assit is not singleton class because if it is then it should have only one instance is't it??? and i should be able to share data.
    however when i create component usage by passing wd_assist to create_component method it is working.. i am not sure of this behaviour of assistance class.
    correct me if i am wrong...

Maybe you are looking for

  • GRN number for rejected items in sales order

    hi sapgurus, i want to know the grn number for rejected goods in the sales order  consider if i put a sales order for a material named X for 10 quantities and if 5 quantities are rejected i will put GRN for those rejected items and add it to my stock

  • Issues in Report Painter Reports

    Dear All, We are on ECC 6.0. We are using some Report Painter Reports and we are facing the following 2 issues: 1. Authorization For some of the Profitability Reports, we are facing authorization issues. e.g. If I do not need a user to view the profi

  • Unknown error occured (2002),unknow error occurred (2003) please help!

    my iphone can not live, I plug into itunes, itunes can not squeeze my mendeteksinya.kemudian sleep + home button for 12 seconds and then I remove the sleep button and keep holding the home button. iphone finally detected. itunes iphone then showed th

  • Bluetooth conectivity with windows vista

    I have just downloaded all the new updates 683.14.1. I still can not get the Bluetooth to work between my n73 & my vista computer. Can anybody help, thank you Ian

  • Where can i enrol in the new service to download betas

    as they stated in their presentation that there is a new program for non-developers to download betas, so i just wanted to know is it live yet and is it free?? how can i access it? thank you.