cancel
Showing results for 
Search instead for 
Did you mean: 

How to extend controller in transaction app

Former Member
0 Kudos

Hi,

I'm extending sales order creation app to send Z order type while placing the order. I extended oData service and it is working fine when Z order type is sent.

I extended SalesOrderReviewCart.controller.js and modified salesOrderCreate function in the extended controller and deployed.

While placing the order, above extended controller is not triggering and order is creating with OR order type.

I didn't find much information on extending / replacing controllers. Can anyone help on this? Thanks in advance.

Component.js

Regards,

Chaitanya.

Accepted Solutions (0)

Answers (3)

Answers (3)

sanchal
Explorer
0 Kudos

Hi Chaitanya.,

Make changes by comparing your code with below. Remove Type:XML from controller extension.

Also, check if you have mentioned, standard app name while loading extended bsp's component like below in component.js.

sap.ui.component.load({

  name: "cus.sd.salesorder.create", 

  url: jQuery.sap.getModulePath("cus.sd.salesorder.create.Create_SalesExtension") +

"/../SD_SO_CRE" // provide parent project url

  // we use a URL relative to our own component; might be different if

  // extension app is deployed with customer namespace

});

Regards,

Bhagyashree.

Former Member
0 Kudos

Hi Bhagyashree,

Here is my Component.js code,

=====================================================================================

jQuery.sap.declare("cus.sd.salesorder.create.SD_SO_CREExtension.Component");

// use the load function for getting the optimized preload file if present

sap.ui.component.load({

  name: "cus.sd.salesorder.create",

  url: jQuery.sap.getModulePath("cus.sd.salesorder.create.SD_SO_CREExtension") + "/../SD_SO_CRE" // provide parent project url

  // we use a URL relative to our own component; might be different if

  // extension app is deployed with customer namespace

});

cus.sd.salesorder.create.Component.extend("cus.sd.salesorder.create.SD_SO_CREExtension.Component", {

  metadata: {

  version : "1.0",

  config : {

  "sap.ca.i18Nconfigs": {

  "bundleName":"cus.sd.salesorder.create.SD_SO_CREExtension.i18n.i18n"

  },

  "sap.ca.serviceConfigs": [{

  name: "SRA017_SALESORDER_CREATE_SRV",

  serviceUrl: "/sap/opu/odata/sap/ZSRA017_SALESORDER_CREATE_SRV/",

  isDefault: true

  }],

  },

  customizing: {

  "sap.ui.viewReplacements": {

  "cus.sd.salesorder.create.view.SalesOrderCreatePriceAndAvailabilityCheck": {

  viewName: "cus.sd.salesorder.create.SD_SO_CREExtension.view.SalesOrderCreatePriceAndAvailabilityCheckCustom",

  type: "XML"

  }

  },

  "sap.ui.viewReplacements": {

  "cus.sd.salesorder.create.view.SalesOrderReviewCart": {

  viewName: "cus.sd.salesorder.create.SD_SO_CREExtension.view.SalesOrderReviewCartCustom",

  type: "XML"

  }

  },

  "sap.ui.controllerExtensions": {

  "cus.sd.salesorder.create.view.SalesOrderReviewCart": {

  controllerName: "cus.sd.salesorder.create.SD_SO_CREExtension.view.SalesOrderReviewCartCustom",

  }

  }

  }

  }

});

=====================================================================================

Regards,

Chaitanya.

sanchal
Explorer
0 Kudos

Chaitaanya,

Could you please share your LPD_CUST configuration. Check if you have mentioned 'cus.sd.salesorder.create.SD_SO_CREExtension' in Additional information.

Regards,

Bhagyashree

chanumanthu
Discoverer
0 Kudos

Path in additional information is appropriate. If it is wrong launch pad will throw "Couldn't start the app" error.

Regards,

Chaitanya.

former_member182372
Active Contributor
0 Kudos

What exactly is the problem? Did you deploy extension as BSP? Do you launch the extension BSP app or original?

Former Member
0 Kudos

I extended sales order creation app using eclipse IDE (JUNO), UI5 version 1.20.9.

Changes made in extension app:

============================

salesOrderCreate function has been extended in SalesOrderReviewCart.controller.js to send Z order type from the app. (corresponding oData service has been extended to read this Z order type).


This is working fine (order is creating with Z order type) when app is tested on Tomcat server in eclipse.


Deployed extended application and configured in launchpad. Through launchpad, app is not triggering this Z oData service while placing the order. You can see the console log attached in previous reply where standard oData service is triggering when trying to process through launchpad.

Please let me know if you need any further info. Thanks in advance.

Regards,

Chaitanya.

former_member182372
Active Contributor
0 Kudos

In dev tools do you see Component.js loading from z_sd_co_creext BSP app?

code looks ok to me, and the fact it works from tomcat (through proxy) is promising. try to run the app directly through index.html

Former Member
0 Kudos

I'm getting below error message in console while executing app directly through index.html

CustomerContext: error while loading personalization service: Cannot read property 'getService' of undefined

Regards,

Chaitanya.

nishantbansal91
Active Contributor
0 Kudos

Hi Chaitaanya,

I have faced the same issue. The file that SAP has generated there is some problem while defining the  of the fragement name.

Can you please share the screen shot of the console for better understanding.

Thanks

Nishant

chanumanthu
Discoverer
0 Kudos

Hi Nishant,

Here is the console log.

Regards,

Chaitanya.