0

I developed a Java application using S4Hana SDK. After deploying the application to SAP Cloud platform, I set the destinations as an environment variable with below command.

cf set-env firstapp destinations '[{name: "ErpQueryEndpoint", url: "https://URL", username: "USER", password: "PASSWORD"}]'

Now, I would like to add a second destination for the same application. Can someone please help me?

Thanks, Sankeerth

Sankeerth
  • 249
  • 3
  • 12

1 Answers1

0

You can define multiple destinations in the environment variable. It is a JSON array.

cf set-env firstapp destinations '[{name: "ErpQueryEndpoint", url: "https://URL", username: "USER", password: "PASSWORD"},{name: "ErpQueryEndpoint2", url: "https://URL", username: "USER", password: "PASSWORD"}]'

In the execute method in the virtual data model you can define which destination to use:

BusinessPartnerService service = new DefaultBusinessPartnerService();

final List<BusinessPartner> businessPartners =
        service.getAllBusinessPartner().execute(new ErpConfigContext("ErpQueryEndpoint2"));

However, better than using the environment variables is to use the destination service.

Step 4 of the SDK tutorials explains how to use this service: https://blogs.sap.com/2017/05/21/step-4-with-sap-s4hana-cloud-sdk-calling-an-odata-service/

With that it is even possible to have destination configurations per tenant.

  • Thank you for the response. This solution helps me. I wonder if we can set these destinations in subaccount level rather than setting destinations for each application. In Neo environment, I am able to set the destinations in subaccount level. But Can we do the same way in cloud foundry? – Sankeerth Apr 04 '18 at 15:55
  • Using the destination service, you can set the destinations on subaccount account level and on destination service instance level (e.g. per space). – Daniel Kurzynski Apr 05 '18 at 07:25