Search code examples
odatasapui5

Wait for response from ui in ABAP Odata


I am trying to make an ABAP OData, that receive a request, does some calculation, then, should return a message to the End User and make an decision based on the user input. So basically, the OData service should be put "on hold", before its receives a response.

Does anyone have a good idea?

Appreciate your response. Regards!


Solution

  • OData is a special kind of REST. REST is stateless. What you want is stateful.

    The good way to do turn this stateful flow into a stateless one is:

    Send a first request (REST: POST, OData: CREATE) that creates and saves(!) a document that represents the calculation and its result. That first request may return the calculation's result to be presented to the user.

    The user's choice then sends a second request that addresses the previously created document (e.g. via a GUID) and includes the user's choice. This means the second request neither has to send the computation input again, nor does it actually perform any calculations; it only changes the existing object's state.

    If the calculation is not needed anymore afterwards, that second request may delete it. To prevent data leakage, removing older calculations after a time limit (e.g. 24h) may be a wise move.