我使用S4Hana SDK开发了一个Java应用程序。将应用程序部署到SAP Cloud平台后,我使用以下命令将目标设置为环境变量。
cf set-env firstapp destinations '[{name: "ErpQueryEndpoint", url: "https://URL", username: "USER", password: "PASSWORD"}]'
现在,我想为同一个应用程序添加第二个目标。有人可以帮助我吗?
谢谢, Sankeerth
答案 0 :(得分:5)
您可以在环境变量中定义多个目的地。它是一个JSON数组。
cf set-env firstapp destinations '[{name: "ErpQueryEndpoint", url: "https://URL", username: "USER", password: "PASSWORD"},{name: "ErpQueryEndpoint2", url: "https://URL", username: "USER", password: "PASSWORD"}]'
在虚拟数据模型的execute方法中,您可以定义要使用的目标:
BusinessPartnerService service = new DefaultBusinessPartnerService();
final List<BusinessPartner> businessPartners =
service.getAllBusinessPartner().execute(new ErpConfigContext("ErpQueryEndpoint2"));
但是,使用环境变量比使用目标服务更好。
SDK教程的第4步说明了如何使用此服务: https://blogs.sap.com/2017/05/21/step-4-with-sap-s4hana-cloud-sdk-calling-an-odata-service/
有了它,甚至可以为每个租户提供目的地配置。