cancel
Showing results for 
Search instead for 
Did you mean: 

How to Insert/Update data base on condition with SAP c4c OData?

former_member273875
Participant
0 Kudos

Dear experts,

After creating new custom BO and its Odata service, now I want to do some checking before create new BO in Odata.

If A already exists in system(check field A, field B and field C), I will update it and otherwise I will create new BO.

With Post method, system always create new item I don't know how to check exist to update it

With Put method, it required to pass ObjectID to update that record but ObjectID is generated by Odata, I don't want external system to store it.

Could you please give me your advice? Thanks a lot for your help!

Regards,

Huy-Nguyen

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member273875
Participant
0 Kudos

Hi Vignesh,

Thanks a lot for your suggestion. That means this requirement cannot be done in server side, right?

Regards,

Huy-Nguyen

Vignesh_Dh
Participant

Hi Huy-Nguyen,

Not all can be implemented in Server side for your requirement.

The solution I proposed is one of the approach we can take to get the solution, with that approach you dont have to store the ObjectID in other system also , because in the step one (GET request) you will get the ObjectID to pass in the PATCH method to update the record.

Regards,

Vignesh

Vignesh_Dh
Participant
0 Kudos

Hi Huy-Nguyen,

It should be a client side logic.

It can be implemented in the client (Java, C#, C4C ABSL or any program capable of doing a REST call) which is calling the C4C OData Service.

Sample algorithm in client side should be as below:

1) Use GET method ($filter parameter) to check if an instance with (check field A, field B and field C) exists

2) If an instance with the check exists, use PATCH method to update the instance with the Object ID returned in the step 1

3) If the instance check in the step 1 failed, Use POST method with necessary payload to create new instance of the BO


Regards,

Vignesh