cancel
Showing results for 
Search instead for 
Did you mean: 

OData don't connect, Data Set not defined

Former Member
0 Kudos

I used automatical OData connection with SAP Web IDE. Unfortunately, data don't connect and Layout Editor says that Data Set "not defined". I have tried to connect by coding, for example<Table items={/Stats}>, but it doesn't work either. When I use project template (Master-Detail or Worklist), there are no problems with connection and Data is automatically connecting, but when I want to make my project and make a connection, there are always some problems.

I don't really understand the difference between template OData connection and my connection. I cannot find this very important difference in a code.

It's picture how connect data with template. I have local installation of SAP Web IDE and I would like to connect SAP Backend.

There are some code samples of automatical connection to my project. I hope that you can help me understand what should I add that my project could connect to database.

Component.js

sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/Device",
"Statusverwaltung/model/models"
], function(UIComponent, Device, models) {
"use strict";

return UIComponent.extend("Statusverwaltung.Component", {

    metadata: {
        manifest: "json"
    },
    config : {
        "resourceBundle" : "i18n/i18n.properties",
        "titleResource" : "SHELL_TITLE",

        "serviceConfig" : {
            name: "UI5STAT1_SRV",
            serviceUrl: "/sap/opu/odata/kernc/UI5STAT1_SRV/"
        }
    },


    /**
     * The component is initialized by UI5 automatically during the startup of the app and calls the init method once.
     * @public
     * @override
     */
    init: function() {
        // call the base component's init function
        UIComponent.prototype.init.apply(this, arguments);

        // set the device model
        this.setModel(models.createDeviceModel(), "device");
    }
});

});
Manifest.json

{
"_version": "1.1.0",
"sap.app": {
    "_version": "1.1.0",
    "id": "Statusverwaltung",
    "type": "application",
    "i18n": "i18n/i18n.properties",
    "applicationVersion": {
        "version": "1.0.0"
    },
    "title": "{{appTitle}}",
    "description": "{{appDescription}}",
    "sourceTemplate": {
        "id": "servicecatalog.connectivityComponent",
        "version": "0.0.0"
    },
    "dataSources": {
        "UI5STAT1_SRV": {
            "uri": "/sap/opu/odata/kernc/UI5STAT1_SRV/",
            "type": "OData",
            "settings": {
                "odataVersion": "2.0",
                "localUri": "webapp/localService/UI5STAT1_SRV/metadata.xml"
            }
        }
    }
},
"sap.ui": {
    "_version": "1.1.0",
    "technology": "UI5",
    "icons": {
        "icon": "",
        "favIcon": "",
        "phone": "",
        "phone@2": "",
        "tablet": "",
        "tablet@2": ""
    },
    "deviceTypes": {
        "desktop": true,
        "tablet": true,
        "phone": true
    },
    "supportedThemes": ["sap_hcb", "sap_bluecrystal"]
},
"sap.ui5": {
    "_version": "1.1.0",
    "rootView": {
        "viewName": "Statusverwaltung.view.View",
        "type": "XML"
    },
    "dependencies": {
        "minUI5Version": "1.30.0",
        "libs": {
            "sap.ui.core": {},
            "sap.m": {},
            "sap.ui.layout": {}
        }
    },
    "contentDensities": {
        "compact": true,
        "cozy": true
    },
    "models": {
        "i18n": {
            "type": "sap.ui.model.resource.ResourceModel",
            "settings": {
                "bundleName": "Statusverwaltung.i18n.i18n"
            }
        }
    },
    "resources": {
        "css": [{
            "uri": "css/style.css"
        }]
    },
    "routing": {
        "targets": {
            "View": {
                "viewType": "XML",
                "transition": "slide",
                "clearAggregation": true,
                "viewName": "View",
                "viewId": "View"
            }
        }
    }
}
}

neo-app.json

 {


    "welcomeFile": "/webapp/index.html",
  "routes": [
    {
      "path": "/resources",
      "target": {
        "type": "service",
        "name": "sapui5",
        "entryPath": "/resources"
      },
      "description": "SAPUI5 Resources"
    },
    {
      "path": "/test-resources",
      "target": {
        "type": "service",
        "name": "sapui5",
        "entryPath": "/test-resources"
      },
      "description": "SAPUI5 Test Resources"
    },
    {
      "path": "/sap/opu/odata",
      "target": {
        "type": "destination",
        "name": "v01",
        "entryPath": "/sap/opu/odata"
      },
      "description": "V01 description"
    }
  ],
  "sendWelcomeFileRedirect": true
}


.project.json

  {
  "projectType": [
    "sap.watt.uitools.ide.fiori",
    "sap.watt.uitools.ide.web",
    "sap.watt.saptoolsets.fiori.project.ui5template.smartProject",
    "sap.watt.saptoolsets.fiori.project.uiadaptation"
  ],
  "build": {
    "targetFolder": "dist",
    "sourceFolder": "webapp"
  },
  "generation": [
    {
      "templateId": "ui5template.basicSAPUI5ApplicationProject",
      "templateVersion": "1.32.0",
      "dateTimeStamp": "Mon, 17 Oct 2016 08:28:52 GMT"
    },
    {
      "templateId": "servicecatalog.connectivityComponent",
      "templateVersion": "0.0.0",
      "dateTimeStamp": "Mon, 17 Oct 2016 10:10:52 GMT"
    },
    {
      "templateId": "uiadaptation.changespreviewjs",
      "templateVersion": "0.0.0",
      "dateTimeStamp": "Tue, 18 Oct 2016 08:08:06 GMT"
    }
  ],
  "translation": {
    "translationDomain": "",
    "supportedLanguages": "en,fr,de",
    "defaultLanguage": "en",
    "defaultI18NPropertyFile": "i18n.properties",
    "resourceModelName": "i18n"
  },
  "basevalidator": {
    "services": {
      "xml": "fioriXmlAnalysis",
      "js": "fioriJsValidator"
    }
  },
  "codeCheckingTriggers": {
    "notifyBeforePush": true,
    "notifyBeforePushLevel": "Error",
    "blockPush": false,
    "blockPushLevel": "Error"
  },
  "mockpreview": {
    "mockUri": "/sap/opu/odata/kernc/UI5STAT1_SRV/",
    "metadataFilePath": "webapp/localService/UI5STAT1_SRV/metadata.xml",
    "loadJSONFiles": false,
    "loadCustomRequests": false,
    "mockRequestsFilePath": ""
  }
}

metadata.xml

<edmx:Edmx
    xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
    <edmx:DataServices
        xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="2.0">
        <Schema
            xmlns="http://schemas.microsoft.com/ado/2008/09/edm" Namespace="UI5STAT1_SRV" xml:lang="en">
            <EntityType
                xmlns:sap="http://www.sap.com/Protocols/SAPData" Name="Stat" sap:content-version="1">
                <Key>
                    <PropertyRef Name="Line"/>
                </Key>
                <Property Name="Layout" Type="Edm.String" Nullable="false" MaxLength="4" sap:label="Planning layout"/>
                <Property Name="Obart" Type="Edm.String" Nullable="false" MaxLength="2" sap:label="Object Type"/>
                <Property Name="Kokrs" Type="Edm.String" Nullable="false" MaxLength="4" sap:label="CO Area"/>
                <Property Name="Line" Type="Edm.String" Nullable="false" MaxLength="10" sap:label="Counter"/>
                <Property Name="Pjahr" Type="Edm.String" Nullable="false" MaxLength="4" sap:label="Planning year"/>
                <Property Name="Version" Type="Edm.String" Nullable="false" MaxLength="3" sap:label="Version"/>
                <Property Name="Status01" Type="Edm.Decimal" Nullable="false" Precision="6" Scale="0" sap:label="Active (St >= 3)"/>
                <Property Name="Status02" Type="Edm.Decimal" Nullable="false" Precision="6" Scale="0" sap:label="Active (St >= 3)"/>
                <Property Name="Status03" Type="Edm.Decimal" Nullable="false" Precision="6" Scale="0" sap:label="Active (St >= 3)"/>
                <Property Name="Status04" Type="Edm.Decimal" Nullable="false" Precision="6" Scale="0" sap:label="Active (St >= 3)"/>
                <Property Name="Status05" Type="Edm.Decimal" Nullable="false" Precision="6" Scale="0" sap:label="Active (St >= 3)"/>
                <Property Name="Status06" Type="Edm.Decimal" Nullable="false" Precision="6" Scale="0" sap:label="Active (St >= 3)"/>
                <Property Name="Status01Perc" Type="Edm.Decimal" Nullable="false" Precision="6" Scale="2"/>
                <Property Name="Status02Perc" Type="Edm.Decimal" Nullable="false" Precision="6" Scale="2"/>
                <Property Name="Status03Perc" Type="Edm.Decimal" Nullable="false" Precision="6" Scale="2"/>
                <Property Name="Status04Perc" Type="Edm.Decimal" Nullable="false" Precision="6" Scale="2"/>
                <Property Name="Status05Perc" Type="Edm.Decimal" Nullable="false" Precision="6" Scale="2"/>
                <Property Name="Status06Perc" Type="Edm.Decimal" Nullable="false" Precision="6" Scale="2"/>
                <Property Name="LayoutText" Type="Edm.String" Nullable="false" MaxLength="40" sap:label="Longtext"/>
                <Property Name="Status01Text" Type="Edm.String" Nullable="false" MaxLength="20" sap:label="Description"/>
                <Property Name="Status02Text" Type="Edm.String" Nullable="false" MaxLength="20" sap:label="Description"/>
                <Property Name="Status03Text" Type="Edm.String" Nullable="false" MaxLength="20" sap:label="Description"/>
                <Property Name="Status04Text" Type="Edm.String" Nullable="false" MaxLength="20" sap:label="Description"/>
                <Property Name="Status05Text" Type="Edm.String" Nullable="false" MaxLength="20" sap:label="Description"/>
                <Property Name="Status06Text" Type="Edm.String" Nullable="false" MaxLength="20" sap:label="Description"/>
            </EntityType>
            <EntityContainer Name="UI5STAT1_SRV" m:IsDefaultEntityContainer="true">
                <EntitySet
                    xmlns:sap="http://www.sap.com/Protocols/SAPData" Name="Stats" EntityType="UI5STAT1_SRV.Stat" sap:content-version="1"/>
                </EntityContainer>
                <atom:link
                    xmlns:atom="http://www.w3.org/2005/Atom" rel="self" href="./kernc/UI5STAT1_SRV/$metadata"/>
                    <atom:link
                        xmlns:atom="http://www.w3.org/2005/Atom" rel="latest-version" href="./kernc/UI5STAT1_SRV/$metadata"/>
                    </Schema>
                </edmx:DataServices>
            </edmx:Edmx>
Former Member
0 Kudos

Hi,

I think you should re-tag your question and put it under SAPUI5 as it is not really related to the SAP Business Client. You have more chance of getting an answer in the SAPUI5 area.

Thanks,
Simon

Accepted Solutions (0)

Answers (2)

Answers (2)

jamie_cawley
Advisor
Advisor

You do not have a default model defined in your manifest.json. Under sap.ui5.models, below the i18n entry try adding

,
"": {
    "dataSource": "UI5STAT1_SRV",
	"settings": {
    }
}

Regards,

Jamie

SAP - Technology RIG

Former Member
0 Kudos

Thank you! Right now it's working!