Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

[SOLVED] SAP RAP: Modify ENTITIES in the respond (Unmanaged Implementation)

rachidroughi
Explorer
1,007

Hello Guys,

I am working on a RAP Service type: "Unmanaged Implementation"

And I would like to modify the ENTITIES values in the respond. Below my POSTMAN request, when I execute it (POST), I want to fill the parameter: "RESERVATION" in the RESPOND.

rachidroughi_0-1714549405360.png

Here my Service Exposition and Method:

rachidroughi_1-1714550061699.png

rachidroughi_0-1714549993410.png

Here my Business Definition:

rachidroughi_1-1714549562702.png

Here my CDS:

rachidroughi_2-1714549627653.png

Here my Behavior Class:

rachidroughi_3-1714549715201.png

I added the code:

rachidroughi_0-1714563379822.png

And when I execute the request, i have an issue:

 

 
"code": "BEHAVIOR_CONTRACT_VIOLATION",
"message": "ABAP Runtime error 'BEHAVIOR_CONTRACT_VIOLATION'",

It's normal because ENTITIES is defined as IMPORTING parameter.

How can I do specify ENTITIES as CHANGING ?

Any idea?

Best regards,

Rachid

 

 

 

4 REPLIES 4

nicmon
Explorer
0 Kudos
741

Hi Rachid! hope you are doing fine. I'm facing a similar issue, were you able to find a solution to change the response? Thanks!

0 Kudos
589

Hi Nicmon,

Hope you are doing well too.

In fact, it is not possible to execute 2 actions simultaneously in a web service. This is part of the general architecture of web services.

You cannot update data (POST) and retrieve data (GET) in a single action.

It's like in a car, you can't shift into one gear with a manual transmission and expect to move forward (GET) and reverse (POST) at the same time.

You need to perform 2 actions separately: POST and after the GET method.

Best regards,

Rachid

0 Kudos
499

Hi! Thanks for the answer!

But for example how does the API_SALESORDER_SIMULATE works?

It seems to be a RAP service you can call as a POST with some basic sales order data and then in the response you can have extended details like Items, Partners, etc (even if they are not in the BODY of the Request).

We are trying to do something similar but can’t find a way to edit that response.

Thanks!

0 Kudos
466

Hi,

I just told you that it is not possible to update the response in the JSON when updating data in SAP.

SAP does not allow modifying the return data during a POST request.

So, if you choose to update the data via the POST method, you will need to send afterwards a GET request to retrieve the extended details such as items, partners, etc...

Regards,
Rachid