Skip to Content
0
Jul 18, 2019 at 12:19 PM

Calling "oDataModel.read" before "Return"

188 Views Last edit Jul 19, 2019 at 04:18 AM 2 rev

Hello All,

While executing function 'returns' statement gets called before my oDataModel.read statement, that is causes empty parameter passing.

how do i call oDataModel.read first & then call 'return' statement.

kindly let me know if information is required.

var sUrl = "/sap/opu/odata/sap/(some name)/";
        var oDataModel = new sap.ui.model.odata.v2.ODataModel(sUrl, false);
        var oPlant = new sap.ui.model.Filter("Plant", sap.ui.model.FilterOperator.EQ, oContext.getAllData().Plant);
        var oStatus = new sap.ui.model.Filter("Status", sap.ui.model.FilterOperator.EQ, oContext.getAllData().Status);
        var oPriority = new sap.ui.model.Filter("priority", sap.ui.model.FilterOperator.EQ, oContext.getAllData().priority);
        var oFilter = new Array(new sap.ui.model.Filter({
            filters: [oPlant, oStatus, oPriority],
            and: true
        }));

            oDataModel.read("(some name)", {
            filters: oFilter,
            success: function (results, error) {
                //sap.m.MesageToast.show(results);
                var data = results.results;

                for (var i = 0; i < data.length; i++) {
                    aCustomSelectionVariant07.push({
                        path: "InspectionLot",
                        value1: data[i].InspectionLot,
                        operator: "EQ",
                        value2: null,
                        sign: "I"
                    });
                }
                //      var aCustomSelectionVariant07 =[];
                var oCustomSelectionVariant07 = {
                    path: "InspLotRsltRecgStatus",
                    operator: "BT",
                    value1: "1",
                    value2: "2",
                    sign: "I"
                };
                aCustomSelectionVariant07.push(oCustomSelectionVariant07);

                oCustomSelectionVariant07 = {
                    path: "InspectionLotType",
                    operator: "BT",
                    value1: "10",
                    value2: "11",
                    sign: "I"
                };
                aCustomSelectionVariant07.push(oCustomSelectionVariant07);


            },
            error: function (error) {
                sap.m.MesageToast.show(error);

            }
            return {
                selectionVariant: aCustomSelectionVariant07,
                ignoreEmptyString: true
            };
},