1

I have configured the information for accessing my OData Service from SAP UI5 in the manifest.json

{
"sap.app": { ...
    },
    "dataSources": {
        "Test": {
            "uri": "/sap/opu/odata/sap/ZHCM_SRV/",
            "type": "OData",
            "settings": {
                "odataVersion": "2.0",
                "localUri": "localService/metadata.xml"
            }
        }
    } ...
"sap.ui5": {
    "rootView": {
        "viewName": "test.view.App",
        "type": "XML",
        "id": "app"
    }, ...
    "models": {
        "i18n": {
            "type": "sap.ui.model.resource.ResourceModel",
            "settings": {
                "bundleName": "test.i18n.i18n"
            }
        },
        "Test": {
            "type": "sap.ui.model.odata.v2.ODataModel",
            "settings": {
                "defaultOperationMode": "Server",
                "defaultBindingMode": "TwoWay",
                "defaultCountMode": "None"
            },
            "dataSource": "Test"
        }
    },
    "routing": { ...
}

In my Component.js I have:

init: function() {

        UIComponent.prototype.init.apply(this, arguments);

        this.getRouter().initialize();

        this.setModel(models.createDeviceModel(), "device");

        // I get the Url from configuration in Manifest.json
        var sServiceUrl = this.getMetadata().getManifestEntry("sap.app").dataSources["Test"].uri;

        // I create the OData 
        var sabModel = new sap.ui.model.odata.v2.ODataModel(sServiceUrl);

        // Load the MetaData.
        sabModel.getServiceMetadata();

        // Binding to the Model.
        this.setModel(sabModel, "Sabbatical");

when I am checking the oModel I can see I have instantiated the Model but it is empty, no data... Have you had this behavior? Any suggestion???

Thanks a lot!! CBR

Jaro
  • 1,757
  • 1
  • 15
  • 36
RaulCB
  • 79
  • 9
  • Is the issue now resolved with https://stackoverflow.com/q/46898423/5846045? In that case, I'd suggest to remove this question in favor of the other one. – Boghyon Hoffmann Jan 23 '20 at 17:52

1 Answers1

0

What you have done so far is: set up a connection to the model.

If you want to fill it with data you can do so by either binding the model to a UI element, e.g. a table, or by reading the data programmatically: sap.ui.model.Model getProperty().

In your case you'd call

var yourVariable = sabModel.getProperty('path/to/your/property');
Inizio
  • 2,226
  • 15
  • 18
michel luther
  • 279
  • 1
  • 2
  • 11