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
In my previous blog you learnt how to author and deploy rules from SAP Cloud Platform Business Rules to SAP HANA (XSC) system but I keep receiving lot of queries on how to deploy business rules to SAP HANA (XSA) system – and in this blog I will address this and show you how to do that.

Before I begin let me brief you on the intension and the need of the two different deployment models.

SAP HANA is an in-memory data platform supporting both analytical and operational processing, including transactional support – and mixes of these as well - to meet wide range of requirements. Beside the database capabilities, SAP HANA has many extra features like predictive analytics, text search and mining etc. Taking advantage of these core HANA processing capabilities, SAP planned to embed a set of applications and web-server within SAP HANA – and so SAP HANA extended application services (XS) was first launched with SAP HANA SP05 release.

As requirements change over time, so did the architecture of these extended application in SAP HANA. With SAP HANA SP11 release, there was evolution of application architecture with the rise of SAP HANA XS Advanced, which leveraged the power of previous architecture but expanded the technical scope with more choices on development technologies (like node.js, javascript), tools and deployment options. The old architecture was thus named as XS Classic (XSC) and the new architecture was named as XS Advanced (XSA).

Both XSC and XSA were completely different in concept - with new advanced models, tools, and application servers. While migration tool was available, but the complete 100% migration was not possible instead it needed a redesign to handle the conceptual differences. This was around 2016. XSC is now deprecated. In SAP HANA 2.0, XSA has become the framework recommended (as default) for new native application development. From SAP HANA delivery strategy, XSC will be supported in SAP HANA 1.0 SPS 12 and SAP HANA 2.0 but shall be removed from later versions of SAP HANA.

This recommendation was thus studied and meticulously applied to business rules framework in SAP HANA. SAP HANA Rules Framework was the rules technology developed on top of SAP HANA XSC and will be supported until HANA supports XSC – but eventually you need to migrate to XSA – and then you also have to migrate your business rules.

SAP Cloud Platform Business Rules is the tool to author, manage and deploy business rules based on SAP HANA XSA data models. In this blog, I am going to explain you how-to achieve that. As most of the concept remains same as for XSC, I will only cover the differences here and rest you can read from my previous blog.

 

Preparations in SAP HANA system



  1. Install or upgrade your SAP HANA to 1.0 SP12 or 2.0 SP02 or above to ensure that it has XSA

  2. HDI Container, schema and tables must be created in the SAP HANA system



  1. .hdbconfig file should be written to the container


 

User Permissions



  1. User that will deploy the business rules must have:

    • SELECT privilege on source schema (which contains the tables on which the rules are written). For Example: I want to deploy rules with my user (ARCHANA) so here is the object privileges I need to assign to the source tables:





 

 

  • HDI Container object owner i.e. <container-name>#OO (where the rules’ related SQL procedure and other artefacts would be generated) must have SELECT privilege to the source schema (which contains the tables on which the rules will be written)


For Example: I created SAPHRFTELCO_PULL hdi container to store the rules’ generated procedure and so when I do that SAPHRFTELCO_PULL#OO will be created. So, I need to assign SELECT privilege on SAPHRF_TELCO schema (which contains the table on which my rules are written)



 

  1. User that will execute the procedure must have

    • SELECT and EXECUTE privilege on the HDI Container schema and tables




 

note: there might be change in the user permissions based on changes from SAP HANA. Please adapt them accordingly.

As direct deployment of business rules from SAP Cloud Platform Business Rules is not yet available in the product, here is a small utility MTAR (multi-target application) that need to be set up in your SAP HANA XSA environment. This will enable you to explicitly call deployment of business rules based on XSA data models.

Disclaimer: This MTAR is not part of the standard product. Using this MTAR, I help you show how to use standard deploy API + further cleansing of the output + to create XSA based procedure that act as business rules runtime artefact. There might be changes needed to adapt to your requirements.

Setup configuration file



  1. Download the hdi-util-parameters.mtaext config file from the GitHub, enter the following information and save the file in your local file system:



  • URL: This is the SAP HANA host URL (keep the URL in single-quotes)

  • User: SAP HANA User which will use connect to the SAP HANA and access HDI Container, Schema and Tables (ensure this user have all required privileges as defined above)

  • Password: SAP HANA user password

  • cloud-host: bpmrulesrepository destination URL from SAP Cloud Platform

  • cloud-user: cloud platform user that has repository role

  • cloud-password: cloud platform user password

  • proxy-host: <keep the host same if you do not have a different proxy setting>

  • proxy-port: <keep the port if you do not have a different proxy setting>


 

See the sample here:
_schema-version: "3.1"
ID: com.sap.brms.hdi.util.extension
extends: com.sap.brms.hdi.util

resources:
- name: hdi-util-parameters
parameters:
config:
user: Lorin
password: Manager123
url: 'http://myhanasystem.sap.corp:8000'
tags: 'xsa-system'
cloud-host: 'https://bpmrulesrepositorytest-test.eu1.sap.hana.ondemand.com'
cloud-user: Archana
cloud-password: mypassword123
proxy-host: 'proxy.wdf.sap.corp'
proxy-port: '8080'



Instructions to setup utility MTAR



  1. Download the MTAR from the GitHub

  2. Log on to the HANA XSA system by executing this command from your system command-prompt (for windows user) or terminal (for mac user):


xs login -a <hana-host>:3<instance-number>30 -u <user-name> -p <user-password> --skip-ssl-validation

For Example:
xs login -a http://myhanasystem.sap.corp:30030  -u Lorin -p Manager123 --skip-ssl-validation


 

  1. Select a space.Enter all required data for your communication arrangement, such as:

  2. Run this command to deploy the utility file:


xs deploy <path-to-MTAR-file> -e <path to hdi-util-parameters.mtaext file>

For Example:
xs deploy assembly/target/rules-hdi-util.mtar -e hdi-util-parameters.mtaext


 

  1. Wait the deployment to finish



 

  1. Check if the application is available, run this command


xs app

See if you have rules-hdi-util listed in the application list:



note: From the output, copy the URL. This would needed as host when you run the deploy API. 

 

Once you have deployed is successfully, a rest endpoint is available (to call deployment of the business rules service) from your application in SAP HANA:

  • <<URL-copied-above>>/rules-service/odata/rule_inbound_srv/hdi-deploy/{container name}/{rulesserviceid}

  • Request Method: POST

  • Headers: Content-Type: application/json

  • Authorization: None


Example:

URL:  "http://myhanasystem.sap.corp:51043/rules-service/odata/rule_inbound_srv/hdi-deploy/SAPHRFTELCO_PUL.../703dd5026eec44f295cfbd1bbbd5b2ef"

 

Prerequisite Configurations



  1. Setup Cloud Connector, Setup Rules HANA Connector and Configure Destination in Cloud tenant. 


[read from previous blog]


 

Configuration in SAP Cloud Platform Business Rules



  1. Annotation in Data Objects and Attributes:


Choose annotation for data object as HANA HDI and configure the required fields as shown. Ensure that the schema name, table name and namespace exists



Similarly define annotation for each attribute of the data object





  1. Annotation in Rule service:


Choose HANA Advanced as the annotation type.



.. and provide required details as follows:


Source Namespace and Source Container: details respective to SAP HANA XSA artefacts where the generated SQL procedure for business rule will be generated.


Target Namespace, Target Container and Target Synonym: provide details if you wish the rules procedure to be created in the synonym.



.. that’s the only configurations you need to make – Annotations to data objects, attributes and rule-service. Rest you model remaining artefacts like rules and ruleset as usual.


 

  1. Activate all the rule artefacts


Finally, before you call the deployment service, you need to ensure that all the rule data models like project, data objects, rule-service, rules and ruleset are saved and activated successfully.


 

  1. Call the deployment utility API


In step 1 above you have deployed the MTAR which creates a rest endpoint to call the deployment. In this example, I have used POSTMAN rest client to do so, you can call the same from your application or any other rest client:


 


 

where:




  • SAPHRFTELCO_PULL is the HDI container where the procedure will be generated

  • 703dd5026eec44f295cfbd1bbbd5b2ef is the rule service ID that has to be deployed


 

  1. Check the generated rules procedure in SAP HANA


Once the deployment is successful (you will get 200 OK as response), a SQL procedure (for the rule service) and table types (one for each input and result usage type as described in the rule service vocabulary). The SQL Procedure will be generated in the source container as specified in rule service annotation.


 


 

With one-time setup of this application in your SAP HANA system, you can use it to deploy your business rules built on XSA data objects. Please note: this content is purely for example. It is not maintained or upgraded and it not delivered as part of the product. The source code must be adapted accordingly (if needed) based on your requirements.

 

Related Blogs
SAP Cloud Platform Business Rules – Extensions and Consumption Patterns
Embed Business Rules SAPUI5 control in your custom applications
Using Business Rules in SAP Cloud Platform Workflow
Integration with SAP HANA (XSC)
6 Comments