cancel
Showing results for 
Search instead for 
Did you mean: 

ODATA is Getting triggered Twice.

Former Member
0 Kudos

Hi,

We are developing Fiori apps by using SAP Standard template SAPUI5 Master Detail Templates, assign ODATA to UI5 Controls like Master List, Combo Box etc.... while testing and understanding data flow between ODATA and UI5 I noticed ODATA is getting called twice, difference between two calls IT_ORDER import parameter is filled with PROPERTY = key field Ex: ZZField1 and ORDER = asc. I can simply check and avoid one call, but I want to know the purpose of calling twice or somewhere something wrong?

Thank you !

San.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Sergio and Maksim,

Thank you very much for your reply.

I noticed it is triggered twice I'm developing app with SAP Web IDE and I'm using standard template i have not written any logic to get data.

Cheers,

San

former_member182372
Active Contributor
0 Kudos

show details of each request (select and on the right)

those are batch requests, could be enything

Former Member
0 Kudos

Hi Maksim,

It is happening to all Get Entity set Methods in my app example Master Detail app Master List, in edit screen Drop down controls, Combo box etc.. other Work list is template also same Work list getting triggered twice.

Here is my detail screen..

Cheers,

San.

oliver_moessner2
Explorer
0 Kudos

Hi,

I have no solution for double call, but I can report the same behavior.

I have build a service using transaction segw, afterwards I bound this service to a master detail fiori template.

The method behind the entity set is called twice, which makes no sense in my eyes

No code was changed/added at the WEB IDE

Regards

Oliver

Former Member
0 Kudos

Hi,

Any one knows solution for this issue?

To replicate the issue simply create a project in SAP web IDE by selecting master detail template, put break point in your back end Get Entity set method, then refresh your app it will be called twice.

Cheers,

San....

former_member205488
Active Participant
0 Kudos

Hello!

If you check the request parameters you could get that the second call contains parameter $count:

IO_TECH_REQUEST_CONTEXT->request->parameters (to check this - perform a widening cast to type /iwbep/cl_mgw_request)

You could check this parameter in implementation of OData method to skip the excess request. Like this:

METHOD get_entityset.

   DATA lo_request TYPE REF TO /iwbep/cl_mgw_request.

   DATA ls_req_details TYPE /iwbep/if_mgw_core_srv_runtime=>ty_s_mgw_request_context.

   FIELD-SYMBOLS <ls_param> LIKE LINE OF ls_req_details-parameters.

    TRY.

       lo_request ?= io_context.

       ls_req_details = lo_request->get_request_details( ).

        READ TABLE ls_req_details-parameters ASSIGNING <ls_param>  WITH KEY name = '$count'.

        IF sy-subrc = 0 AND <ls_param>-value = 'X'.

         EXIT. "method

       ENDIF.

      CATCH cx_root.

   ENDTRY.

"...


ENDMETHOD.

Former Member
0 Kudos

Hi Vadim,

Thank you for your reply.

but I'm not able to find any import or global variable with the name "io_context".


any other alternative?


Cheers,

San.




former_member205488
Active Participant
0 Kudos

Sorry, it was a snippet from my program.

I mean the import-parameter IO_TECH_REQUEST_CONTEXT in method *GET_ENTITY(). Use it instead of io_context.

Former Member
0 Kudos

Thank you Vadim..

You are the best.

Cheers,

San

Answers (4)

Answers (4)

michal_keidar
Active Contributor
0 Kudos

Hi ,

This user is using UI5 templates, maybe you can assist with why these calls are done twice?

Thanks,
Michal.

0 Kudos

Hello All,

I am working in the team responsible for the templates. I have just generated an app from the "SAP Fiori Master-Detail Application" template in the version "1.34".

I have checked the network trace. There are 2 batch calls:

1) get all products

2) get the selected product


The second call is done intentionally, as some stuff for this object might not have been fetched with the first list call. Is your feedback that this second call is not necessary?


regards Thomas

oliver_moessner2
Explorer
0 Kudos

Hello Thomas,

it is possible to have this call optional.

From my point of view, there are two scenarios:

1. the datastructure is simple so you can load the data in one try, the overhead of a a second call for each entity is too expensive

2. the data is complex, so the list contains only a small data subset of an entity, a reload of each single entity is required.

We have both cases and we would appreciate to have both cases based on performance reasons

Regards

Oliver

0 Kudos

Hi Oliver,

thanks for the insight. I was not sure if both scenarios are valid.

We see a lot of variations in the template's usage and do not want to add too much complexity to the template generation process. For this case we will only generate one of the above scenarios and document the manual adaption for the other one. Which of your 2 scenarios is the more common one from your perspectice (and as such be part of the template)?

regards Thomas

oliver_moessner2
Explorer
0 Kudos

Hi Thomas,

hard to say, depends on the complexity of the UI.

I like your solution of implementing one way and document how to set up the other. Which adaption (from customer not SAP view) is more easy. Having the more complex way implemented and a guide to simplify it, is the preferred solution from a customer point of view. 🙂

Hope this helps

Oliver

0 Kudos

... well really it's more complicated. There is a reason why both Master and Detail view load their data independently of each other:

- The master view is displaying the data with a growing list. Means only the N first items are loaded and shown. Only when scrolling down further more items are getting loaded.


- The detail shows the object identified in the hash of the URL (by the way: even if you start the app with an empty hash the app will set the hash to the selected item).

=> you cannot rely in the Detail view that the object identified by the hash will be in the N first items loaded by the master. Yould could wait for the master to load it's items and only then trigger the second call BUT with this you will trigger the 2 requests sequentially and get slower in this case.

Former Member
0 Kudos

Hi Thomas,

Thank you for your reply.

I noticed two calls triggered for  two purposes one to get actual data, another call is to get count means number of records, this is useful for controls like Object List view, Table etc.. as they load data based on paging if you display count like Total(n)  we need the second call to get count, but controls like ComboBox, Input Field with suggestion or F4 doesn't require second call, anyway there is a way to control in Get Entity set method so no issue.

Cheers,

San..

0 Kudos

Hi all,

we are currently in the process to document this behavior. Attached you will find the current proposal. Please feel free to feed back.

Maybe also some additional comments on that:

the first call requests count plus 1..n entities from the collection

the second call fetches an entitiy as reflected by the hash.

As these are batch calls the count comes at no significant extra price.

best! Thilo

former_member182372
Active Contributor
0 Kudos

is property in IT_ORDER equal to Zhrlvtype? to sort by it, so request is generated by binding. are you sure you don't read or bind to ETY_LEAVE_TYPESSet somewehere else in your code?

SergioG_TX
Active Contributor
0 Kudos

San,

can you provide a screenshot of the network calls? even though it looks like it is called twice, it may be due to the call only completing once, perhaps?

junwu
Active Contributor
0 Kudos

ur code, please.

Former Member
0 Kudos

Hi Jun,

Thank you for your reply..

I'm using XML and Js Views, My XML Code for Combo box is.

<ComboBox enabled="{= ${viewModel>/mode} === 'edit'? false: true}" items="{ path: '/ETY_LEAVE_TYPESSet', sorter: { path: 'Zhrlvtype' } }"

                                                placeholder="{i18n>leaveType}" value="{Zhrlvtype}">

<core:Item key="{Zhrlvtype}" text="{Subtx}"/>

</ComboBox>

Cheers,

San..