cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing OData property value in entity

0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Hi,

You can simply use named models.

You can name the models.

Your objectHeader code will look like below:

<ObjectHeader binding="{entityA>/ProductCollection}" title="{Name}">

<attributes>

<ObjectAttribute text="{entityA>WeightMeasure} {entityA>WeightUnit}" />

<ObjectAttribute text="{entityB>/Width} x {entityB>/Depth} x {entityB>/Height} {entityB>/DimUnit}" />

</attributes>

<ObjectHeader>

Hope it will help,

Best Regards,

Rajvardhan Thakare