cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

UPSERT in OData Service

Former Member
2,564

Dear SAP experts,

we have found the following help page which introduces the use of the UPSERT method in OData services:

https://help.sap.com/viewer/e0cd7c1ecf3d4f2f9feb46ec1c5b68fb/1905.500/en-US/07b1d8e18d924f5ba8bf5275...

Unfortunately, it's not explained how to implement it. Furthermore, we can't understand if the UPSERT method updates only the header or also the items of a Custom Business Object.

Can you kindly help us?

We'd like to use the UPSERT method instead of doing the call to SAP Marketing Cloud in order to retrieve the SAP UUID and then use the POST (in case of SAP_UUID blank) or the PUT method.

Thank you.

Regards.

Andrea

Accepted Solutions (1)

Accepted Solutions (1)

former_member226
Employee
Employee

Hi Andreas,

We are using "Upsert" in our project for storing header information for employees and by looking at the structure of the URL parameters, I doubt that you can update items attribute as well, But may be some one from SAP can confirm about the same.

From implementation point of view here are steps:

1. Create a CBO. make sure "Service Generation" is checked while publishing the CBO.

2. Generate create a Custom Communication Scenario and Arrangement.

3. call the metadata URL and get the upsert FunctionImport/Action name. To get the metadata URL, refer the inbound service URL in Communication arrangement to be created in step 2.

communication-arrangement.png

4. From metadata just look for string called "Sap_upsert" and you shuld be able to locate the Function Import.

function-import-xml.png

5. Considering y CBO structure is :

ID: CHAR10 (KEY)

Name: Char 50

Email: Char 50

Then the URL to be fired for upsert operation will look something like this:

https://my30XXXX-api.s4hana.ondemand.com/sap/opu/odata/sap/YY1_EMPLOYEE_CDS/YY1_EMPLOYEESap_upsert?ID='123'&Name='Employee 2'&Email='bllll@sap.co.in' --> This is a POST Call without body and With CSRF token

Here YY1_EMPLOYEE is my CBO ID and YY1_EMPLOYEESap_upsert is my function import which i got from step 3. Rest ID, Name, Email are my fields. These are case sensitive and recommendation is to check the metadata for exact field ID.

Important thing to note is, You need to pass all fields of root node to URL even if only 1 f the fields is updated.

Hope it helps a bit.

Thanks

Saurabh

Former Member
0 Kudos

Dear Saurabh,

thank you very much for your answer and detailed explanation!

I'll wait for a confirmation for SAP in order to understand if also the items can be updated using the upsert.

In the meanwhile, I'm going to test the upsert function on the header of my CBO.

Thank you again.

Regards.

Andrea

Answers (1)

Answers (1)

Former Member
0 Kudos

Dear SAP experts,

can anyone confirm if the UPSERT method can be used to update also the items of a CBO or only the header?

Thank you.

Regards.

Andrea