cancel
Showing results for 
Search instead for 
Did you mean: 

Maintain stateful Odata service

Former Member
0 Kudos

Hi All,

   

   I have developed a Sencha Extjs application in which i am using ODATA (from Tcode SEGW) to get the data from the backend  and in the GET_ENTITYSET of data provider class method i am initially getting data from dbtable into global variable (class attribute).
and now when i update the data from the front-end  and save it. the UPDATE_ENTITY method is called . and here i want to access the data stored in that global variable save in the  GET_ENTITYSET method ( instead of getting from the database again )

Here, the odata is stateless.How can i maintain its state to stateful.?

And here i provide a small piece of my code.

METHOD carrid_get_entityset.

   IF mt_test IS INITIAL.

       SELECT * FROM ztest2 INTO CORRESPONDING FIELDS OF TABLE mt_test.

   ENDIF.

ENDMETHOD.

METHOD carrid_update_entityset.

" Now i want to access  data in mt_test  here but it is initial.

ENDMETHOD.


Any help could be appreciated. Thanks in advance.

Regards,

Shiva

Accepted Solutions (0)

Answers (2)

Answers (2)

kammaje_cis
Active Contributor
0 Kudos

Shiva,

Just to extend Andre's answer,

You cannot retain data between a get_entity set call and update entity call. (That is stateless. Each call is on its own and independent).

You need to pass the data to be updated as request body ( also called as payload) of your update request.

Thanks

Krishna

Former Member
0 Kudos

Hi Andre and Krishna,

Thanks for your response.

Yes, i am able to perform the update operations in the database by writing the UPDATE statement in the update_entity method.

But in that update_entity method i want to make some validations for the new entry(in the grid) by checking it with my old entries , which i am not  able to retain it (from the get_entity method).

As i think i have two options of doing this task done.

1. Doing validations in the front-end and send data to update request only if valid.

2. Get the data from the database by writing SELECT statement in the update method every time.    (Performance Problem).

Is there any way by which i can get my old entries from the grid in the update_ entity method.?

Regards,

Shiva

kammaje_cis
Active Contributor
0 Kudos

Shiva,

Whenever you create a web application for Update operation, it is common that you present the current data and ask the user to make changes.

So I feel that it is better to validate at the application level rather than inside the update method.

Thanks

Krishna

Former Member
0 Kudos

Hi Krishna,

Client-side validation with OData is possible but I would not suggest it as best practice. Part of the concept of OData services is the openness of data transport and the separation of business logic, so you can request the input of any data you wish. Without server side validation this is extremely risky.

The validation on client side will normally be simple, i.e. do we have the complete data that we think the request requires and are the values valid as far as we know? (In this case I can't see how "validation" is possible by simply comparing old and new)

This might be supplemented by some function imports that provide lookup tables, but otherwise I would expect the business rules to execute on the BEP server which is also the system of record in most cases. If the data is not acceptable, a BUSI exception should be raised by the update/create method - that is what it is there for.

@ Shiva: OData is not a replacement for Web application frameworks; if the application is that complex, consider using one of the integrated frameworks like WD or BSP which will allow embedded MVC behaviour and better integration with the business logic.

Regards

Ron.

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Shiva,

the OData protocol is meant to be stateless.

What you can do however is to maintain the state on client side.

Best Regards,

Andre