sap-cloud-sdk

How to perform Create with navigation in S/4 HANA SDK


We are trying to perform POST operation using S4 HANA SDK.Our Use case is to add a child entity to an already created parent entity.

We are trying along these lines

final BusinessPartnerService service; // your BusinessPartner service
final BusinessPartner abcBusinessPartner; // fetched businessPartner
final BusinessPartnerRole newRole; // your role, for example created by: BusinessPartnerRole.builder(). ... .build();

abcBusinessPartner.addBusinessPartnerRole(newRole);

service.updateBusinessPartner(abcBusinessPartner);

We get back the following error from the on-premise system.

{
  "error": {
    "code": "/IWFND/CM_MGW/096",
    "message": {
      "lang": "en",
      "value": "PATCH requests require components to be updated"
    },
    "innererror": {
      "application": {
        "component_id": "MM-PUR-REQ",
        "service_namespace": "/SAP/",
        "service_id": "MMPUR_REQ_SSP_MAINTAIN_SRV",
        "service_version": "0001"
      },
      "transactionid": "94EEA58F4E630230E005D1A751652A34",
      "timestamp": "20190708061130.8418390",
      "Error_Resolution": {
        "SAP_Transaction": "For backend administrators: run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and search for entries with the timestamp above for more details",
        "SAP_Note": "See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)"
      },
      "errordetails": []
    }
  }
}

Solution

  • Based on the blog :: https://blogs.sap.com/2018/09/17/sap-s4hana-cloud-sdk-version-2.4.1-is-available/

    For the use case of creating a child entity we have to use the .asChildOf qualifier while creating .

    Eg :: new DefaultBusinessPartnerService() .createBusinessPartnerAddress(addressToCreate) .asChildOf(parentBusinessPartner, BusinessPartner.TO_BUSINESS_PARTNER_ADDRESS) .execute();