cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP RAP - REST API with Draft Mode not working

tobias2022
Explorer
0 Kudos

We want to create a RAP service and use it both with a Fiori Elements app and as a web api. The prerequisite is the use of OData V4, with which I am forced to turn on the DRAFT mode.

The Fiori App works so far and I can create/edit entries etc..

In addition, I have now created a new service binding as a web API and am trying to create a record using postman and POST.

Unfortunately the created record is only created in the draft table.

How do I get the record persisted now?

Or do I have to create new CDS-Views/Behavior Definitons without DRAFT?

Thanks 🙂

Accepted Solutions (0)

Answers (3)

Answers (3)

iandsalveson
Explorer
0 Kudos
dominik_ee
Advisor
Advisor
0 Kudos

Hi Tobias,

you can check the requests sent by your application in the browser developer tools under network. When hitting "Save" on a draft instance a batch request is sent which contains the execution of two actions: Prepare and Activate. During the preparation determinations and validations of your BO are called if specified. If the preparation is executed successfully, the activation can be executed. This persists the data stored in your draft in the active database table.

For more details you can check the documentation.
Prepare:
https://help.sap.com/docs/BTP/923180ddb98240829d935862025004d6/8eb32c2936904f95acffaec95ab1edd5.html

Activate:
https://help.sap.com/docs/BTP/923180ddb98240829d935862025004d6/a53cb0362b4c499f8488b7ab7c70e387.html

iandsalveson
Explorer
0 Kudos

Hi Tobias,

My understanding of RAP framework and the Draft Lifecycle is that the draft actions as listed below would need to be implemented. The create operation is used create a new draft instance hence why you wouldn't see any data in the persistent table. Once a draft instance is compete, it has to be activated in order for the details to be persisted.

draft action Resume;

draft action Edit;

draft action Activate;

draft Discard;

tobias2022
Explorer
0 Kudos

Thanks Ian.

Does the service that wants to create an entry have to send a second post to activate the entry?

Then I rather build a second service without draft mode for the api