Skip to Content
0

Call an update method from a fiori Object page

Oct 18, 2016 at 03:57 PM

179

avatar image
Former Member

Hello dear experts,

i'm new in fiori/ sapui5 and i'm working now on a fiori project. i use a worklist template for that. On both pages i have actions(approve and reject.. most act identically on both pages). These Buttons trigger a change in my data and call an update function(crud) to also change the odata in the backend. I use for that ajax, this work pretty fine on the List page. But make trouble in the object/detail page.

Here i perform an update in my backend (Worklist.js) / Worklist page

var batchChanges = [];
                var oUpdateModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/Z_XNEU_SRV/");

jQuery.ajax({
                    // Data request 
                    type: "GET",
                    contentType: "application/json",
                    url: "/sap/opu/odata/sap/Z_XNEU_SRV/",
                    dataType: "json",
                    async: false,
                    success: function() {
         for (i = 0; i < aSelectedItem.length; i++) {
                        // Change Datafield in oUpdateModel
                        //...
             //perform batch operation for backend (PUT)
                            batchChanges.push(oUpdateModel.createBatch                            Operation(
                                sPath,
                                "PUT",
                                oContractObject));
          }
// refresh odata
                        oUpdateModel.addBatchChangeOperations(batchChanges);          
                        oUpdateModel.submitBatch(function(data) {
                            oUpdateModel.refresh();
                        }

and here the update in object.js (object page)

var batchChange = [];
            var oUpModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/Z_XNEU_SRV/");

            jQuery.ajax({
                // Data request 
                type: "GET",
                contentType: "application/json",
                url: "/sap/opu/odata/sap/Z_XNEU_SRV/",
                dataType: "json",
                async: false,
                success: function() {
                    oContractObject = oView.getBindingContext().getObject();
                    // Change Datafield in oUpModel
                    //...

                //perform batch operation for backend (PUT)
                    batchChange.push(oUpModel.createBatchOperation(
                        sPatch,
                        "PUT",
                        oContractObject));
                oUpModel.addBatchChangeOperations(batchChange);
                    oUpModel.submitBatch(function(data) {
                        oUpModel.refresh();

                 });
                }

            });
                

in the object page there is just one object selected, so i don't need a loop when i perform the changes. The "sPatch" and "oContractObject" are filled correctly but the "PUT"-operation don't work for the Object page. Please i need help. Don't understand why..

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers