cancel
Showing results for 
Search instead for 
Did you mean: 

Extending My Quotations Error

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi DD,

We still haven't resolved this issue yet. We actually just put the field we need on another oData call. Unfortunately our next enhancement really requires us to put the new field in quotationitem entity.

Let's keep this thread open and alive so the experts here can help us.

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

Have you tried replacing the original service? 

I'm assuming you are using the Web IDE, so,

  1. choose File -> New -> Extension. 
  2. Click Next
  3. Choose Replace Service
  4. Under Sources choose Service Catalog and under Service Information, choose the system that the service belongs to.  Then search for your service and select it. Click Next
  5. Click Finish.

Your metadata.xml file should be updated with the information from your backend service.

Hope this helps.

Cheers,

Kevin

Former Member
0 Kudos

Hi Kevin,

Yes I am using Web IDE. I did the steps you stated but it is still calling the original service. Do I need to replace the service calls from the controller itself?

kammaje_cis
Active Contributor
0 Kudos

I would suggest you to have separate threads for different issues. That way you increase the possibility of more people looking into your problem. Also it would help users facing similar issues to identify the right thread.

Former Member
0 Kudos

Hi Krishna,

I thought that the right service call not being called is relevant to my error. But I will do as you suggested.

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Kevin,

We already have the correct values in Component.js but we are still getting the error.

kammaje_cis
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

HI Krishna,

You mean ZLORD_MY_QUOTATION_SRV/QuotationSet?

kammaje_cis
Active Contributor
0 Kudos

yeah.. I meant /sap/opu/odata/sap/ZLORD_MY_QUOTATION_SRV/QuotationSet)

Sorry for the typo.

Former Member
0 Kudos

Okay! We will try this.

Do you think we need to extended anything in CreateQuotations.controller.js? Though it is not yet mandatory to show the sales order id in that view also.

Former Member
0 Kudos

Hi Krishna,

Do you happen to know how to redefine the method? Can you share some documentations on how to do this?

Thank you.

kammaje_cis
Active Contributor
0 Kudos

You need to go to *DPC_EXT class for the service.

Then you identify the method in this class, select it and hit the redefine method.

Former Member
0 Kudos

Hi Krishna,

I think we don't need to redefine ZLORD_MY_QUOTATION_SRV/QuotationSet. Since we are not going to use this on the next view.

As per console logs. I error seems to be on ActionSet service call.

Anyone have an idea on the error?