SAP / cloud-sdk-js

Use the SAP Cloud SDK for JavaScript / TypeScript to reduce development effort when building applications on SAP Business Technology Platform that communicate with SAP solutions and services such as SAP S/4HANA Cloud, SAP SuccessFactors, and many others.
Apache License 2.0
162 stars 56 forks source link

Support for upsert operation #4459

Closed memgavdilabs closed 2 months ago

memgavdilabs commented 7 months ago

Hi team,

Is your feature request related to a problem? Please describe. We are using the sap cloud sdk (js) for batch requests to a SAP Successfactors instance since it is not provided out of the box by SAP CAP. SAP Successfactors have a lot of entities where only upsert is supported to add/change records. An example of a standard SAP SF entity is EmpJobRelationships which contains the employee relationship information to one or more managers. The metadata for such an entity in successfactors is defined as: `

EmpJobRelationships Contains the employee relationship information to one or more managers. Employee Central (EC) EC - Employment Information
            </EntitySet>`

Based on the definition sap:creatable and sap:updatable are false leaving us with only using upsert.

Describe the solution you'd like We would like support for upsert operation in such cases, so we could also use it in batch operations.

Describe alternatives you've considered To process the request without use of sap cloud sdk batch feature. This surely introduces complications with data integrity as we cannot take advantage of the changeset feature of data submission.

Impact / Priority We are developing an application to terminate employee relationships in SAP SF, based on employee transfers/exits. In scenarios where a manager leaves the organization or moves to another team, we would like to update all the EmpJobRelationships of all the subordinates of this manager, so it could be a big chunk of data that needs updating hence we would need the batch with upsert.

Affected development phase: Development

Impact: Inconvenience, Impaired

Timeline: Go-Live is in 5 weeks.

jjtang1985 commented 7 months ago

Thanks for reaching out @memgavdilabs.

The upsert is a OData v4 feature that SDK does not support for the time being. I found a nice blog post here for the upsert as well.

Unfortunately, this is not planned for the near future and I'll leave it open for now. Maybe talking to CAP, so they can consider supporting batch and upsert :)

Best regards, Junjie

memgavdilabs commented 7 months ago

Hi @jjtang1985

The upsert is used extensively by SAP Successfactors in OData V2 version. I looked into the metadata of a SAP Successfactors instance and in the edmx file, they have defined the upsert as follows: <FunctionImport Name="upsert" ReturnType="Collection(SFOData.UpsertResult)" EntitySet="UpsertResult" m:HttpMethod="POST" sap:support-payload="true"></FunctionImport>

If i generate the cloud sdk odata client for this function import, it creates a typed operation called upsert(), but with empty parameters, so i am unable to pass the data payload as a parameter to the upsert operation. Further it also gives a warning regarding the reserved keyword name upsert.

Is there any solution to this ?

Regards, Melwyn

deekshas8 commented 7 months ago

Hi @memgavdilabs,

We discussed the support for upsert operations in the team, I will open a ticket to investigate the effort and what the API could look like. Could you share a link to the service spec of the SuccessFactors service you are using? Then I can check how it's generated and if support is easy.

As a workaround, I can suggest using the generic client to execute plain HTTP requests.

jjtang1985 commented 2 months ago

Using the generic client is the recommendation for now. I'll close this ticket, as we won't be able to work on it, with the current priority.