SAP Cloud Platform Business Rules was released for enterprise consumption in Cloud Foundry environment last month (help portal). In my previous blogs, I have explained how to subscribe to the business rules in CF (blog1) and also to consume the service from custom application (blog2). In this blog I will address how-to embed business rules or rule builder control in an application.
Most of the coding to embed the business rules SAPUI5 control in CF application is same as described in my previous blog but there are some fundamental and configurational changes that are needed due to the multi-target application development.
please note: This is not a step-to-step guide instead it would just address the additional things you need to successfully enable decision-table or text control in your CF application.
- Create MTA-project (you can do that from WebIDE in neo environment)
(developing MTA applications)
- Create HTML5 Module
- Code the application to embed business rules
(see the blog)(help on developing HTML5 module)
- In the yaml file you need to configure the app-router, the xsuaa binded to the app-router and the business-rules service instance as shown:
… and the same you need to provide as resources in yaml file. Depending upon whether the resource already exists or had be created you define the type as org.cloudfoundry.existing-service or org.cloudfoundry.managed-service respectively.
- Finally, you need to add the routes in the approuter depending upon which business rules APIs (authoring or runtime) you want to call. (know more about syntax)
- Build the mta application.
note: If you are using WebIDE, then before building the application ensure that you have configured your CF account in WebIDE or else you can use CF commands to build your application as well.
note: after you have successfully build the project, you will find the deployable mtar file in mta_archives of your project.
- Right click on the mtar and Deploy the application to SAP Cloud Platform via Deploy –> Deploy to SAP Cloud Platform option
- Once the application is successfully deployed, you can find the URL from the SAP CF cockpit from the space <where the application is deployed> –> Applications
- The final URL will be:
That’s it. It is pretty simple and straight. You can also use this to migrate your Neo application embedding rules editor to CF application. All the steps mentioned above are not specific to business rules, it applies to any CF application calling service APIs.
Sample Reference Application
I have shared a rulesmanager.zip project in GitHub which you can use to learn and reference on how-to embed the business rules in your application. All you need to do is import this application, modify yaml file based on your CF setup, build and then deploy the mtar file.