sap-cloud-sdksap-cloud-foundrys4hana

SAP Cloud SDK for javascript using the destination


I have followed the Tutorial and build the basic CF based nodejs applciation to display all BusinessPartners from my S/4HANA on-premise destination.

function getAllBusinessPartners(): Promise<BusinessPartner[]> {
  return BusinessPartner.requestBuilder()
    .getAll()
    .execute({
      destinationName: 'MockServer'
    });
}

Destination is configured with the Virtual host from cloud connector.

But after deploying to the Cloud Foundry, i get following error for the GET request

{"message":"Service of type destination is not supported! Consider providing your own transformation function when calling destinationForServiceBinding, like this:\n destinationServiceForBinding(yourServiceName, { serviceBindingToDestination: yourTransformationFunction });","level":"warn","custom_fields":{"package":"core","messageContext":"destination-accessor"},"logger":"sap-cloud-sdk-logger","timestamp":"2020-03-09T18:15:41.856Z","msg":"Service of type destination is not supported! Consider providing your own transformation function when calling destinationForServiceBinding, like this:\n destinationServiceForBinding(yourServiceName, { serviceBindingToDestination: yourTransformationFunction });","written_ts":1583777741856,"written_at":"2020-03-09T18:15:41.856Z"}

The application is already bound to the Destination service as well.

Can someone help me here, what went wrong ? or the approach to use destination is different in the new version of Cloud-SDK ?


Solution

  • After lot of attempts, i have made this to work.

    My Observations:

    1. Connectivity service is also required to be bound, when using on-premise S4 backend.

    2. There was no errors in the log, i have made certain modification in the code to use async/await

    async function getAllBusinessPartners(): Promise<BusinessPartner[]> {
      return await BusinessPartner.requestBuilder()
        .getAll()
        .execute({
          destinationName: 'MockServer'
        });
    }

    After this modification, when I hit the GET request, it gave me the following error:

    "Failed to get business partners - get request to http://s4h-scc-basic:500/sap/opu/odata/sap/API_BUSINESS_PARTNER/sap/opu/odata/sap/API_BUSINESS_PARTNER failed!"

    Could notice that the suffix after the http://domain:port is twice. One I gave in the destination, and the other VDM adds automatically. Ideally, this error is supposed to be thrown even before adding async/await.

    After removing the suffix from the destination, it started to work.