on 07-06-2015 11:14 AM
Hi Experts,
We are trying to extended our standard app - My Quotations. Basically we added a new button that will create a sales order if the quotation doesn't have a sales order attached to it yet. If the quotation already has a sales order, he can view the sales order number.
We implemented an FM that will create the sales order whenever the button is clicked. We can successfully create the sales order in the backend but we are encountering an error whenever we edit the quotation.
Below is the error. The SalesOrder property is coming from the last view.
the Odata service call (/sap/opu/odata/sap/ZLORD_MY_QUOTATION_SRV/QuotationHeaderSet('20000027')) on the previous page does have a SalesOrder property to it.
But on the next Odata service call (/sap/opu/odata/sap/ZLORD_MY_QUOTATION_SRV/QuotationSet) doesn't have a SalesOrder property. I wonder if we also need to extend this odata service call.
Also on the have this error when the app calls /sap/opu/odata/sap/lord_my_quotation_srv/ActionSet
Below is our code
manageSalesOrderFields: function() {
alert("manageSalesOrderFields");
var salesOrderId = "";
//hide all fields
view.byId("salesOrderLabel").setVisible(false);
view.byId("salesOrderText").setVisible(false);
view.byId("triggerSalesOrderLabel").setVisible(false);
view.byId("triggerSalesOrderButton").setVisible(false);
$.getJSON("/sap/opu/odata/sap/zlord_my_quotation_srv/QuotationHeaderSet('" + quotationId + "')",
function(data) {
alert("enterHere");
salesOrderId = data.d.SalesOrder;
alert(salesOrderId);
if (salesOrderId !== "" ){
view.byId("salesOrderLabel").setVisible(true);
view.byId("salesOrderText").setVisible(true);
}else{
view.byId("triggerSalesOrderLabel").setVisible(true);
view.byId("triggerSalesOrderButton").setVisible(true);
view.byId("triggerSalesOrderButton").detachPress(sap.ui.controller("...").createSalesOrder);
view.byId("triggerSalesOrderButton").attachPress(sap.ui.controller("...").createSalesOrder);
}
});
},
createSalesOrder: function () {
var createSalesOrderDialog = new sap.m.Dialog("createSoDialog", {
title: "Create Sales Order",
icon: "sap-icon://sales-order",
content: [
new sap.ui.core.HTML({content:"<p style='margin:0;padding: 16px;'>Do want to create a sales order?</p>"})
],
buttons:[
new sap.m.Button({
text: "Yes",
press : function() {
var oModel = new sap.ui.model.odata.ODataModel('/sap/opu/odata/sap/zlord_my_quotation_srv/');
var oParameter = {
"QuotationID" : quotationId
};
oModel.callFunction('/CreateSalesOrder', 'GET', oParameter, 'null',
function (oData, oResponse) {
var responseMessage = JSON.stringify(oResponse.body);
var responseMessageStart = responseMessage.search('<d:Message>');
var responseMessageEnd = responseMessage.search('</d:Message>');
responseMessage = responseMessage.substring(responseMessageStart + 11, responseMessageEnd);
//show MessageToast
sap.m.MessageToast.show(responseMessage);
view.byId("triggerSalesOrderLabel").setVisible(false);
view.byId("triggerSalesOrderButton").setVisible(false);
console.log(responseMessage);
},
function (oError) {
sap.m.MessageToast.show('Error - see log');
console.log(oError);
}
);
createSalesOrderDialog.close();
createSalesOrderDialog.destroy();
}
}),
new sap.m.Button({
text: "No",
press : function() {
createSalesOrderDialog.close();
createSalesOrderDialog.destroy();
}
})
]
});
createSalesOrderDialog.open();
},
If anyone has an idea with this error, it will be a great help to us.
Hi,
In method _callService of the CreateQuotation Controller, the model metadata property is set to the old service
newModel.setProperty("/__metadata",{"type" : "lord_my_quotation_srv.Action"} );
Try to replace this by the new enhance service and check once.
Thanks,
Esha.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
Could you please let me know how did you resolve this issue ?
I have added one field at Quotationitem entiry and getting same error when i click on Edit button .
Thanks in advance for your input .
Thanks,
DD
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi experts,
While waiting for our OData enhancement to finished. I just noticed that the app is calling the old OData service when I clicked the edit button.
Instead of calling ZLORD_MY_QUOTATION_SRV/ActionSet, the view is calling /sap/opu/odata/sap/lord_my_quotation_srv/ActionSet. I tried to extended the next view also, changing all calls of lord_my_quotation_srv to ZLORD_MY_QUOTATION_SRV but it's throwing me an error of Uncaught TypeError: Cannot read property 'read' of undefined
Should I be extending the next view also (CreateQuotation.controller.js)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Have you tried replacing the original service?
I'm assuming you are using the Web IDE, so,
Your metadata.xml file should be updated with the information from your backend service.
Hope this helps.
Cheers,
Kevin
Hey HMN,
In the Component.js file, there is a section called this.****.Component.extend. Inside here, you can set the service config... so something like this
this.hcm.approve.timesheet.Component.extend("hcm.approve.timesheet.HCM_TSH_APV_DIR_INDIR.Component", {
metadata: {
version: "1.0",
config: {
"sap.ca.serviceConfigs": [
{
name: "<you component name>",
serviceUrl: "/sap/opu/odata/sap/<your component name>/",
isDefault: true,
mockedDataSource: "./model/metadata.xml"
}
],
},
customizing {
// this is where the IDE would declare any controller extensions.
}
}
Hope this makes sense.
Cheers,
Kevin
Yes, You need to extend the entityset method as well.
I think you already extended ZLORD_MY_QUOTATION_SRV/QuotationHeaderSet('20000027')
This will be in "Read" method.
But "ZLORD_MY_QUOTATION_SRV/QuotationHeaderSet" is a "Query" and in ABAP would point to a different method. So you need to extend (redefine) that method as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.