Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Archana
Product and Topic Expert
Product and Topic Expert
2,263
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.

 

  1. Create MTA-project (you can do that from WebIDE in neo environment)
    (developing MTA applications)

  2. Create HTML5 Module

  3. Code the application to embed business rules
    (see the blog)(help on developing HTML5 module)

  4. 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.



 

  1. 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)



 

  1. 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.


 

  1. Right click on the mtar and Deploy the application to SAP Cloud Platform via Deploy --> Deploy to SAP Cloud Platform option


 

  1. 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



For Example: https://rulesmanager-approuter.cfapps.sap.hana.ondemand.com/sapdemorulescustom/index.html


 


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.

 
8 Comments
shashidhar_peddi
Explorer
0 Kudos
Hi,

I have created a Business rules project in SAP cloud and activated it.

I am trying to test the API, first by calling the XSRF API using postman. I am getting 404 not found error.



 

I then checked the destination in the connectivity section for bpmrulesruntime to see if the connection is up,I'm getting following message:



 

Can you guide me in testing the ruleset that I have created in the project using postman.
Archana
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hello Shashidhar,

The URL used for API is incorrect. Here is the correct one:

Also note these v1 APIs and are deprecated now. Use the v2 APIs
https://api.sap.com/api/SAP_CP_BusinessRules_Runtime_V2/resource

Regards,
Archana
shashidhar_peddi
Explorer
0 Kudos

Hi Archana,

 

Thank you for the quick reply.

I used V1 API for now, but getting following response:

 

However, the project Test1 and Rule Service RSV_001 exist:

 

Also, could you check the passing of parameters in body is correct.

the input structure IM_CARR_CONN contains two elements CARR and CONN of type string.

the result structure EX_FLTID has element FLTID

 

Regards,

Shashidhar

shashidhar_peddi
Explorer
0 Kudos
The rule service was not deployed. Now it is deployed, and I am getting a 200 Response but no response body:



 

How to invoke the rule service so that it returns the correct result?

Also, is there no way to test this directly from the cloud platform UI.

 

Regards,

Shashidhar
shashidhar_peddi
Explorer
0 Kudos
Hi Archana,

What is the URL for v2? I tried different variations, but it does not work.

Regards,

Shashidhar
Archana
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hello Shashidhar,

If you switch Details tab of the API in API Business Hub, you will see the production URL which tell you the URL to be needed. Here are some examples:

https://bpmrulesruntimer<your account>.hana.ondemand.com/rules-service/v1/rules/xsrf-token
https://bpmrulesruntime<your account>.hana.ondemand.com/rules-service/rest/v2/rule-services


Body should be like (you can get the information if you see the Body description of the API in API Business Hub)

{
"RuleServiceId": "281f9d8f63754afeaa37e3c7f0ecb9c6",

"Vocabulary": [
{
"Product": {
"Category": "Flat Screen TVs",
"Quantity": 35,
"Soldby": "Very Best Screens"
},

"Seller": {
"Name": "Very Best Screens"
}
}
]
}
Archana
Product and Topic Expert
Product and Topic Expert
0 Kudos
This is because nothing is matching. Also "__type__" in body is to be your data object name
somnath
Active Participant
0 Kudos

Hello Archana,

Could you please provide certain insights about achieving the same as a local development approach. Means without deploying the code into BTP.

I was trying with default-env.json and tried to place it under rulesmanager_appRouter folder and pasted the VCAP service details from environment variable. But this gets stuck with Auth error.

So do you have any project (Github) to refer which talks about local development and testing locally rather deploying each time to cloud.

Thanks in advance!

  • Regards, Somnath