To add a controller extension in SAP Fiori, you can follow these steps:

  1. Open the SAP Web IDE or Eclipse IDE and create a new SAPUI5 project.
  2. In the project, create a new JavaScript file for the controller extension. The file name should follow the naming convention "{originalControllerName}.controller.js".
  3. In the extension file, define a new controller that extends the original controller. For example, if the original controller is named "MyController", the extension file should contain the following code:
  1. javascriptCopy codesap.ui.define([ 
  2. "sap/ui/core/mvc/Controller" 
  3. ], function(Controller) { 
  4. "use strict"; 
  5.  
  6. return Controller.extend("my.namespace.MyController", { 
  7. // add your extension code here 
  8. }); 
  9. }); 
  1. In the original view XML file, add a reference to the new extension controller. For example, if the original controller is named "MyController", the extension controller should be named "MyControllerExtension". The XML should contain the following code:
  1. phpCopy code<mvc:View controllerName="my.namespace.MyController"> 
  2. <mvc:content> 
  3. <!-- your view content here --> 
  4. </mvc:content> 
  5. <mvc:controllerExtensions> 
  6. <mvc:ExtensionController name="my.namespace.MyControllerExtension" /> 
  7. </mvc:controllerExtensions> 
  8. </mvc:View> 
  1. In the extension controller, you can add new functionality by defining new methods or overriding existing ones. You can also access the original controller by calling the "this.base()" method.
  2. Save your changes and deploy the SAPUI5 project to your SAP system.

That's it! Your SAP Fiori application should now use the new controller extension.

Call us on +91-84484 54549

Mail us on contact@anubhavtrainings.com

Website: Anubhav Online Trainings | UI5, Fiori, S/4HANA Trainings

Comments

Popular posts from this blog