cancel
Showing results for 
Search instead for 
Did you mean: 

OData Query optimization

former_member190010
Contributor
0 Kudos

Hi guys,

I am developing a Gateway OData service, and have one question I would like to clarify with you.

I have a requirement to send to the mobile device 10 different text tables (i.e. TVK1T, TVK2T, TVK3T, etc) using an OData web service.

I see two possible approaches for doing these:

1) Create 10 different entities, one for each table, where each of one will have two properties:

-Code

-Text

This way, I have to define a query operation for each entity and an RFC for each text table in the SAP Backend.

Then, the data can be retrieved from the mobile app using one $bacth request with 10 operations inside.

2) Create one entity that will have the fields:

- Table ID

- Code

- Text

This way, I can retrieve the data for the 10 tables using just one RFC I develop in the SAP Backend.

The mobile app just have to send one request containing one operation.

* In my opiinon, the second one is the best approach because the effort is much less than the first one, and it will be much more performant.

* In your opinion, What is the best approach to follow?

Best Regards,

Emanuel

Accepted Solutions (1)

Accepted Solutions (1)

AshwinDutt
Active Contributor
0 Kudos

Hello Emanuel,

Is it a Read operations or any Modifying operation ( Create / Update /Delete )?

Kindly share how u would like to consume data in your application. Based on that we can suggest to model ur service in a best way.

Regards,

Ashwin

former_member190010
Contributor
0 Kudos

Thank you for your answers.

The operation that need to be done is just Query operations.

I am going to use the data I retrieve to populate some matchcodes.

The requirement is similar to this post:

http://scn.sap.com/thread/3488251

In a few words, I need to populate 10 match codes, and I want to know if it's better to retrieve the data from the mobile app using one $bacth request with 10 operations inside (each operation will differ in an import parameter that will select which matchcode data to return), or to retrieve the data for the 10 matchcodes in just one operation (the data for the 10 different matchcodes will be returned in the same operation, and it will be identified by the "Table ID" field).

What do you think?

AshwinDutt
Active Contributor
0 Kudos

Hello Emanuel,

U r displaying all the data coming from different tables at once on the UI is it ?

That means u will have 10 different table of data as part of GW response based on Table ID is it ?

Will it be only 10 match codes ?

BATCH would be the neat and best approach.

Ur response would be neat and organised. Its easy to access response in UI level.

One more thing is ur service will be flexible so that u can get data of a single table or multiple table based on Table ID.

But since its a Mobile App, u need to think about performance here.

If data retrieved is huge then it may hamper the performance.

But if u see latest SP 09 there is some performance improvements done in BATCH.

Please refer below

$batch Processing - SAP NetWeaver Gateway - SAP Library

Refer below thread as well ->

From SAP NetWeaver Gateway Hub and Backend SPS09 Onwards
  • Custom header ($batch response header) is supported for $batch requests.
  • A selection of generic HTTP headers for $batch requests are available for the data provider when processing each $batch operation.
  • Performance improvement for $batch change-set processing when the data provider is able to handle the entire operation of change set at once at end of change set. For this to be possible, the data provider must implement the change set handling API to process all change set operations within one API (CHANGESET_PROCESS) and return the consolidated result of all operations to the SAP NetWeaver Gateway Framework.


If u r on latest SP 09 u can use BATCH only and can process all the operations at once

Regarding ur second approach i.e., to retrieve the data for the 10 matchcodes in just one operation (the data for the 10 different matchcodes will be returned in the same operation, and it will be identified by the "Table ID" field), 

U can do this somehow but according to me if u look at the GW model point if view , ur GW model will be very rigid here.

U need to have 10 entities and tomorrow if u want to get 11 match codes from 11 different tables then u need to change the model of ur GW again and also the back end code.

If u use BATCH u will not have to do this.

If u think its always 10 entities only and will never change, then u can do a trade off with respect to ur GW model and accomplish through $expand ( Expand Entity/Expand Entity Set), where u can get all those tables of data based on table id in one call.

Regards,

Ashwin

kammaje_cis
Active Contributor
0 Kudos

One Approach:

I would create one entity, but 10 entity sets. Each entityset pointing to the same entity.

In the implementation logic, based on the entity set, I would fetch from different tables.

Other approach:

Also check if the search helps are already existing. If yes, you can use this.

Importing Search Help as a Data Source - SAP NetWeaver Gateway - SAP Library

regards

Krishna

former_member190010
Contributor
0 Kudos

Thank you for your answer.

I like what you said of having one entity, and 10 entity sets.

One question:

When I define the QUERY operation:

The 10 entity sets will be populate at the same time. Is this right?

I mean, there is no possibility to populate just one entity set from the 10, because there is just one operation for the 10 of them.

Thanks in adavance.

kammaje_cis
Active Contributor
0 Kudos

You query one entityset at a time. See OData.org for URL specifications. So you get one entityset at a time.

At backend there is one method, but you send different data for each entityset. (Case or IF and fork your logic)

former_member190010
Contributor
0 Kudos

You are right about the entity sets, sorry that's my mistake.

Just one more question to clarify the whole question.

In the case a READ operation needs to be done, there will be just one entity, therefore there will be one read operation.

Is this right?

Thanks in advance.

kammaje_cis
Active Contributor
0 Kudos

Read URL also contains "EntitySet" name in addition to the keys.

So always you know the 'context'.

Coding approach will be similar to Query.

Answers (1)

Answers (1)

kammaje_cis
Active Contributor
0 Kudos

Emmanuel,

Best approach would depend on the UI. May be you can explain us how does the UI look like which shows this data. Your solution might be completely different.

Your OData model need not reflect the database model, rather it should reflect the UI and the UI navigations.

regards

Krishna