Hi, I provide training in SAP UI5. Also feel free to checkout my new web page https://saptechblog.com
Webdynpro ABAP

Different types of controller in Webdynpro ABAP




The different types of controllers in webdynpro abap are:

  1. Component controller
  2. Custom controller
  3. Interface controller
  4. View Controller
  5. Window Controller


Before learning about the Controllers let us know something about different types of interfaces that are created at the time of creation of the component. These interfaces are as below.

  1. IF_<ControllerName>
  2. IG_<ControllerName>
  3. IWCI_<ComponentName>


The interface begin with the prefix IF is local and can be used for coding only within that controller.

The interface begin with the prefix IG is used for cross controller communication.(E.g View controller to component controller)

The interface begin with the prefix IWCI is used for cross component communication. (E.g. ComponentA to ComponentB)


Component Controller:


There is only one component controller exists per webdynpro component and it is global. i.e Component controller consist of data and processing logic that is available to all the views in the component. This controller does not have any visual interface. The life time of the component controller is the life time of the component.


Components of Component:






In the properties tab of the component controller we can declare the component usage of the other component so that the interface methods of that component can be accessed by the methods of the component controller.






Context is a hierarchial form of storage of data which we will breifly study about it in the upcoming posts. And for now context is a place where you declare the data. The Nodes declared here can be mapped to any no of view and can be accessed from there hence making the data of the component controller global.






The attributes required by the Component controller are declared in the attributes and are accessible to the methods of the component controller using the handle provided for the component controller(WD_THIS). These attributes can also be accessed from different controllers using the handle provided for the component controller(WD_COMP_CONTROLLER) in the respective controller. The attribute WD_THIS declared in any controller refers to the interface of the current controller and the attribute WD_CONTEXT declared referes to the corresponding context of the controller.







Events can be created in component and custom controller.Events created in the component controller are visible only within the component which means it can only be triggered by the methods of the component controller. But it can be handled in different contollers. Thus Events are used to communicate between the controllers and enable one controller to trigger the event and handler the event in different controller. Events can also implement cross component communication provided that the interface check box is checked.







Components controller consist of number of predefined methods called hook up methods which are executed in a pre-defined manner. We will study about these hook up methods in the later posts. We can also created the methods on our own and the methods which we created can be called from any controller using the handle for the component controller(WD_COMP_CONTROLLER).





Custom Controller:


Custom controllers can be additionally created in the component and there are exactly similar to the component controller in terms of functionality. This means it is visible to all the elements in the component and life time of the controller is the lifetime of the component. Any number of custom controller can be created in the component and it provides the option of structuring the datas and functions. It only make sense to create a custom controller if certain function and datas are to be associated with the specific set of views.





The first three components Properties, Context and Attributes are similary to that of component controller and the only differ in the events and method properties.




Events are created and implement in a similar way to the component controller except that they cannot implement cross component communication. It can be handled only within the component.







Unlike component controller the custom controller does not contain a no of hook up methods. We can create own methods in the custom controller and these methods can be used by any views provided that the custom controller is added to the used controller in the properties tab of the view.




Thus these two options resitrict the visibility of the custom controller to protected.



Interface Controller:


Interface controller is used for cross component communication. Interface controller does not contain any implementation. It it the point of contact of communication for other component to use this component. Only nodes, methods and events marked as interfaces can be used by other components.


Components of interface:






In the Properties tab you will be able to see the administration data and Interface that was created for the external communication(IWCI).







In the context tab you will be able to see the context nodes of the component controller which is marked as interface node in the node properties of the component controller.






In the events tab you will be able to see the events which are marked as interface events for cross component implementation.







In the methods tab, you will be able to see the interface methods that can be accessed by the other components.






View Controller:


Each view exactly consist of one view controller. No of view controllers in a component depends upon the no of views. The view controller cares about the view specific flow logic like checking user input, handling user actions etc. The lifetime of the view controller is restricted to the life time of the view.


Components of view:





The properties tab of the view controller consist of the admin data as well as the option to add the used controllers for the view.


In this example I have added the custom controller of the same component as the used component so that the methods of the custom controllers can be accessed in this view.




Layout tab of the view controller provides the option for placing the UI element. It is WYSIWYG type of editor. (What You See Is What You Get).





Inbound Plugs:


Plugs are required for the navigation between the views. Inbound plugs consist plugs which is pointing into the view. Unlike outbound plug the inbound plug consist of event handler method which will be executed before displaying the view.





Outbound Plug:


Inbound plugs consist plugs which is pointing away from the view. This does not contain any event handler method and the outbound plug can be fired using following syntax.









Context as mention earlier is a hierarchial form of data storage and the context node declared in the view can be used only in that corresponding view and it cannot be accessed in anyother views. The node created in the view context does not provide the option for interface node.






Attributes is similar to that of the attribute tab discussed in the component controller. Here in the view controller you will be able to see the handler to the component controller with reference to the interface of the type IG_(Cross controller). Using this handler the attributes and methods of the component controller can be accessed.







Actions tab consist of the onaction events created for the UI elements.







In the methods tab you will be able to see the set of hook methods specific to the view controller and event handler methods created for the UI element actions and own defined methods.





Window Controller:


Each window in a webdynpro component consist of a window controller.  It is visible throughout the component and behaves like component or custom controller.


Components of window controller:






Properties tab of the window controller is similar to that of the view controller.







In the window tab we will be able to see the views that are embedded in the window, inbound and outbound plug of each view  and the view that is marked as default. Here we can also specify the navigation link between the views using the view plugs.




Inbound Plug:


The properties of a window’s inbound plug differ from a view’s inbound plugs by the characteristics Interface and Startup or Resume that can be maintained:




The interface check box determines whether the inbound plug is used only for navigation within the component or cross component navigation.




If the plug type is selected as start up then webdynpro application can be started using this plug. When creating an webdynpro application only the interface view inbound plug can be used. All other type of plugs can only be used for navigation in an already running application. Window inbound plug also has the event handler method. The Plug type suspend and resume are used for portal navigation and will be discussed in later posts.





Outbound plug:


Outbound plugs consist of interfaces, Exit and Suspend characteristics.





Context attributes and methods tab are simliar to that of the view controller except that the method of the window controller has different set of Hook methods.



Note : At run time all the controller instances are singleton.



About Arun


  1. Nice work! Now , I've understood everything about controllers. Thanks!

  2. thanks a lot ...
    very good explanation..

  3. thanks a lot ...
    very good explanation..

  4. Thanks a lot. It is helping me to understand Web dynpro better. You have simplified everything so nicely.

  5. Very good article!! Keep it up

  6. Well explained ..Thanks for sharing the notes

  7. good explanation..

    i have a question that why component controller is global..?


Powered by Blogger.