No upset with CBO ‘Upsert’
By now, we would have come across the CBO(Custom business object) in either Fiori app use cases or Interface use cases… This post is to provide an idea or a tip w.r.t data update using CBO Upsert technique..
Please refer to below articles if you need a kick start:
Creation of CBO –
Maintenance of CBO via Fiori app –
Maintenance of CBO via Interface –
In a nutshell, We have seen Maintenance of CBO or Creation of entries in the CBO in a Single call per entry or a mass creation using $batch call.
However, I want to touch upon the update scenario which is a little different as Patch/Put is not supported directly over the entity (albeit MERGE is technically possible).. SAP Note 2575658 describes UPSERT way to update or create using function import…
The request looks like the following:
In the request above, Function import is CBO entity + Sap_upsert i.e., workitemSap_upsert followed by parameters.. This works like a charm but the only concern is that we have to update 1 entry at a time (per call)
Therefore, Taking this learning a step further we can enhance it to “Create or Update CBO entries in mass” using $batch operation-…
Content-Type: multipart/mixed; boundary=changeset
POST workitemSap_upsert?workitem_cd=’WI123’&WI_status=’In+process’&SAP_Description=’WorkItem+Create’ HTTP/1.1
POST workitemSap_upsert?workitem_cd=’WI123’&WI_status=’Complete’&SAP_Description=’WorkItem+Update’ HTTP/1.1
In the above request ‘WI123’ is created if it doesn’t already exist and updated if it exists…
However, Pls note the below points before going ahead with this $batch option
- There cannot be a blank space in the URI. We have to add a +(plus) if we need a space in the text for ex: SAP_Description=’WorkItem+Update’ would be updated in table as ‘WorkItem Update’
- If any error occurs in the POST the complete call fails…So partial create/update will not happen – which is good in terms of troubleshooting
- Usual $batch limit applies for no. of entries that can be posted (we have observed around 180 entries per call but it varies with the size of the payload)
That is all for this article…will update further if we come across something worth sharing…
Please leave your comments or opinions if you want me to add/update anything..