数据绑定到表错误不是功能

时间:2018-11-21 14:34:47

标签: sapui5

我在将OData绑定到表时遇到问题。当我在js文件中定义函数时,它说“不是函数”

odata.js

getBoM : function(iNumber){


        var sNumber = iNumber.toString();
        while (sNumber.length < 18) {
            sNumber = "0" + sNumber
        }


        var vUriRead = "/ProductHeadSet('12345')/ProductHead2BOM";
        var oResult;

        this.initODataModel( );

        this.oDataModel.read(vUriRead, null, null, false, function(oData, oResponse) {
            oResult = oData;
        }, function(oError) {
              jQuery.sap.log.error("OData-Error in function getBoM (EntityBoMSet)");
              xyz_homepage.xyz_homepage.src.odata.displayRequestFailedMessage(oError);
        });

        return oResult;
    },

Controller.js

var oProductHead2BoM = xyz_homepage.xyz_homepage.src.odata.getBoM(iNumber);

        this.oModelProductHead2BoM.setData(oProductHead2BoM);

在.getBoM(iNumber)处显示,“未捕获的TypeError:xyz_homepage.xyz_homepage.src.odata.getBoM不是函数”

编辑: controller.js

handleRouteMatched : function(oEvent) {
    if (oEvent.getParameter("name") === "page") {
        var iNumber = oEvent.getParameter("arguments").number;

        var oDataResult = xyz_homepage.xyz_homepage.src.odata
                .getDetailsProd(iNumber);
        this.oModelProdManag.setData(oDataResult);

        var aDocuments = xyz_homepage.xyz_homepage.src.odata.getDocumentsProd(iNumber);

        this.oModelDocuments.setData(aDocuments);

        //Call bom routine and set data

        var oProductHead2BoM = xyz_homepage.xyz_homepage.src.odata.getProductHead2BOM(iNumber);

        this.oModelProductHead2BoM.setData(oProductHead2BoM);

因此,当我调试并单击函数“ .getDocumentsProd”时,我可以找到引用odata.js的函数

Odata.js

getDocumentsProd函数

getDocumentsProd : function(iNumber){

        var sNumber = iNumber.toString();
        while (sNumber.length < 18) {
            sNumber = "0" + sNumber
        }
        var vUriRead = "/DocumentsSet/?$filter=Material%20eq%20'" + sNumber + "'";

        var oResult;

        this.initODataModel( );
        this.oDataModel.read(vUriRead, null, null, false, function(oData, oResponse) {
            oResult = oData.results;
        }, function(oError) {
              jQuery.sap.log.error("OData-Error in function getDocumentsProd (EntityDocumentsSet)");
              xyz_homepage.xyz_homepage.src.odata.displayRequestFailedMessage(oError);
        });

        return oResult;

    },

同样,我对getProductHead2BOM函数也有兴趣。

getProductHead2BOM : function(iNumber){

        var sNumber = iNumber.toString();
        while (sNumber.length < 18) {
            sNumber = "0" + sNumber
        }


        var vUriRead = "/ProductHeadSet('5199182')/ProductHead2BOM";
        var oResult;

        this.initODataModel( );

        this.oDataModel.read(vUriRead, null, null, false, function(oData, oResponse) {
            oResult = oData;
        }, function(oError) {
              jQuery.sap.log.error("OData-Error in function getProductHead2BOM (EntityProductHead2BOM)");
              zplm_homepage.zplm_homepage.src.odata.displayRequestFailedMessage(oError);
        });

        return oResult;
    }

我可以看到文档Odata,但不能看到ProductsHeadBom

enter image description here

0 个答案:

没有答案