cancel
Showing results for 
Search instead for 
Did you mean: 

Odata service is called twice in SAPUI5 application

0 Kudos

We have a simple SAPUI5 application using a OData service. When the application is started it lists data from a table.When I set a break-point in the corresponding GET_ENTITYSET method, and then start up the application, I notice that the method is called twice.

The first time with "$count" and the second time without. The data is retrieved twice.

Is this normal?

Did we do something wrong in in our application?

How can we prevent this duplicate call?

Regards, Paul Lauwers

Application Engineer IFF

Accepted Solutions (1)

Accepted Solutions (1)

former_member184867
Active Contributor
0 Kudos

you can call oDatamodel.setCountSupported(false) to omit the $count call

andres_levano
Explorer
0 Kudos

HI Atanu,

I was following this case and I have something similar, but with a different need.  I have a Full Screen template app with some changes. I added a list object and a facet filter object, both linked to the same odata service collection.

It is making many calls to the service (specially the facet filter), the question is, is it possible to make just one call to the service to poblate all the elements, in order to get a better performance?

Is there any configuration in the sap.ui.data.odata.v2 class define to regulate the times app calls a service?

any hint or tip will be very usefull to solve this issue.

thanks in advance.

Andres

former_member184867
Active Contributor
0 Kudos

Hello Andreas,

For better performance probably we  need to check the UI design and odata calls.

It may be possible to aggregate these calls in one batch operation and achieve better performance from Gateway point of view.

But that may also cause some changes in APP UI side as well.

I am not sure if there is any config available in UI5 api for V2 or not.

Regards

Atanu

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi at all,

we have the same issue in


var confirmationModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZMOBILE_RM_SRV", false);

confirmationModel.create('/ES_CONFIRMATION', oEntry, null,

               function(oData, oResponse){

                   showMessage('CONFIRMATION_SUCCESS');

                },

               function(){

               }

             );

we dont know why but it calls the backend function twice. And that leads to 2 created entries instead of one.

i used the set default count mode but it doesnt help.

Can anyone provide another mention about this please ?

EDIT:

i have found another solution on my own try. In the data provider class i commented the second call for a read request after the create call is done.

i do this because the above mentioned set default count doesnt work for me. Here is the code i commented:


* Call read after create

**** wurde ausgeschaltet wegen doppeltem aufruf

*/iwbep/if_mgw_appl_srv_runtime~get_entity(

*  EXPORTING

*    iv_entity_name     = iv_entity_name

*    iv_entity_set_name = iv_entity_set_name

*    iv_source_name     = iv_source_name

*    it_key_tab         = it_key_tab

*    io_tech_request_context = lo_tech_read_request_context

*    it_navigation_path = it_navigation_path

*  IMPORTING

*    er_entity          = ls_entity ).

* Send the read response to the caller interface

*  ASSIGN ls_entity->* TO <ls_data>.

*  er_entity = <ls_data>.

Former Member
0 Kudos

Hi Paul,

In response to the questions: "Is this normal?" & "Did we do something wrong in in our application?", it depends.

Firstly, this is not a duplicate call as the URI scheme is not identical. The GET method can actually be coded to respond differently for a $count option, since a full feed is not required. You can actually return 0-n blank rows to get the correct count response.

I'm not a big fan of this design, since I could easily use a select count(*) in the method to get the number but I actually have to "fill" the entityset 'count result' number of times so that the OData parser can count the feed. This is wasteful of bandwidth, so I have my own model designs to provide better performance where this might be an issue.

Secondly, it is standard practice for Fiori apps to show a count result on the application leader tile, e.g "My Tasks", showing that I have five tasks . That would require the use of a $count option first. I don't know how you produced your code but I am guessing there is a default somewhere in the UI5 SDK that is based on the intent of needing this item count as a standard use case. As per Atanu's answer, you can deprecate this feature in your app if you don't need a lead-in counter shown.

Regards

Ron

Former Member
0 Kudos

Just a further note about counting. I spotted something yesterday. There is a response object property for count that can be populated with the count number. I haven't tested this yet but I am assuming if this is filled it will mean that the OData parser won't need to count the feed and therefore a feed isn't actually required. So I could place 999 in the count and a null feed, which would be much better for performance.