Skip to Content
0

Using calculation view with input parameters in SAPUI5 control

Mar 10, 2017 at 09:56 AM

335

avatar image

Hi guys,

I have a calculaton view which is using an input parameter. The view is exposed as an xsodata sevice. Now, I want to feed data from this view into a set of tiles. The problem is the syntax when referring to specific fields from my view. I can use a syntax like "{RequestsByStatusParameters(IP_Status='02')/Results}, which gives me the "Results" collection - which in my case consists of one single element (the one with IP_Status = '02'). The problem is I cannot find a way to refer to the individual elements (fields) inside this "Results" entity...

I have found forum posts showing how to bind the entire "Results" entity to a table, but that's not what I need. I need to refer to the specific fields inside Results. If I do so, like for instance "...Results/myFieldName", I get an error stating that I can only use $count after "Results", since the "last node is a collection".

My UI5 control - a tile - looks like this:

					<StandardTile 
						id="__RequestsInProgress"
						title="In Progress" 
						icon="sap-icon://settings" 
						info="Requests" 
						number="{NumberOfRequests}"
						infoState="Success" 
						binding="{/RequestsByStatusParameters(IP_Status='SG02')/Results}"
						press=".onRequestsInProgressPressed"/>
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Srikanth KV Mar 10, 2017 at 05:08 PM
1

To refer to the individual element you need to use OData url with Key in the url.

As for the calculation view's XSOData definition is to generate local keys, so at runtime key is generated and we don't what is the key value.

service {
    "sample.odata::view" as "MyView" key generate local "GenID";
}

Only approach I could think of is to perform read operation on the model ...something like model.read() and get the results to perform binding

Share
10 |10000 characters needed characters left characters exceeded
Sergio Guerrero Mar 10, 2017 at 08:41 PM
-2

since you are referring to a data set and you only need one record from the list.. you need to call your end point as you have it.. then basically take the zero index element from the array. did you try this?

/RequestsByStatusParameters(IP_Status='SG02')/Results/0

check out the element binding section:

https://sapui5.hana.ondemand.com/#docs/guide/91f05e8b6f4d1014b6dd926db0e91070.html

Share
10 |10000 characters needed characters left characters exceeded