Skip to Content
0
Mar 25, 2019 at 06:11 PM

Accessing OData property value in entity

786 Views Last edit May 21, 2020 at 04:03 PM 2 rev

Hi,

I just started doing some exercise on SAPUI5, here is my problem description:

I have an objectHeader control which i have binded with Entity_A using bindElement. However i want to bind another value from Entity_B to one of the objectHeader property. How do i do that?

I have set up my on-premise SAP odata service as data source, which verified works in binding to controls (and verified via other exercise). My Manifest.json as following:

"OData":{ "dataSource" : "D30" } --> the destination is properly set up in Hana Cloud Platform Destination setting

-----------------------------------------------

so far, I have tried following:

1. in view controller, getting the value from Entity_B from OData model. Something like following :

var oModel = new sap.ui.model.odata.ODataModel("https://my.sapdomain.com/sap/opu/odata/sap/MYODATA_SRV/"); <--full URL

var value = oModel.getProperty("OData>/EntitySet_B('ABC')/value");

------------------------

2. Also tried accessing Odata model in manifest.json

var oModel = new sap.ui.model.odata.ODataModel("OData"); <-- data source predefined in manifest.json

var value = oModel.getProperty("OData>/EntitySet_B('ABC')/Value")

------------------------

3. Also tried

val value = oModel.read("OData>/EntitySet_B('ABC')/value", { success: function(odata,response){ ... }, error: function(error){ } });

------------------------

4. I haven't tried to instantiate OData model object with "destinations/D30". Which it probably use the ready-set credential to access my Odata service

How do i use instantiate Odata model object using "destination/D30" (which contain the service URL)?

Anybody have any other idea?

Regards

Zen