This blog describes my steps from installing the SAP HANA Rules Framework 1.0 SPS 07 Patch Level 1 and configuring it until creating a HANA Rule and executing a HANA Rule Service with varying HANA Rule Conditions in the end. For further details please refer to SAP Note 2259199 - Release-Informationen zu SAP HANA Rules Framework 1.0 SPS07 and to the SAP HANA Rules Framework's official documentation on SAP Service Marketplace.
The SAP HANA Rules Framework 1.0 SPS 07 can be downloaded from SAP Service Marketplace:
The SAP HANA Rules Framework 1.0 SPS 07 can be downloaded from SAP Service Marketplace:
At the time of this blog, SPS 07 Patch Level 1 was the latest available version:
Please be aware that SAP HANA Rules Framework 1.0 SPS 07 requires SAP HANA SPS 11. For this blog, I have been using the SAP HANA Database Revision 111. However please be aware, that at the time of this blog, there has been no SAP HANA Datacenter Service Point released for HANA SPS 11 yet, so at the time of this blog, you should try this in a sandbox environment only. Please check SAP Note 2021789 - SAP HANA Revision and Maintenance Strategy, whether this is still the case when you read this.
After extracting the ZIP archive, I install the package with the HANA Application Lifecycle Management Delivery Units Import functionality:
After confirming the import of the Delivery Unit:
The imports starts and runs for a little while. Once completed you get a green light and we are ready to proceed:
Next, back in HANA Studio, you have to create a user called HRF_TECH_USER and grant this user the following, to enable rule service consumption:
- sap.hrf::AllPrivilegesForTechnicalUser application privilege
- sap.hrf.role.model::HRF_TECH_ROLE role
Also, you would have to grant your user a series of HANA Rules Framework Roles:
With that preparation we can configure the HANA Rules Framework via REST API. Please configure basic authentication with your user, that you granted the roles above. As a result, you are rewarded with a success message:
And subsequently with access to the Fiori Launch Pad of the SAP HANA Rules Framework at:
With the configuration in the bag, we next deploy the SAP HANA Rules Framework Modelling Tools at:
After confirming the license agreement the software gets installed and you will have to restart SAP HANA Studio.
Next we build a small Point of Sales data model as the basis for our HANA Rules. You find the SQL scripts for these tables and their contents in the appendix at the end of this blog:
Please do not forget to grant both users _SYS_REPO and HRF_TECH_USER SELECT Privileges with Grant Option to the schema of your user. These are needed for the creation and execution of the Rules Service respectively:
Now we create a new XS Project and within that a new Vocabulary based on the tables above:
For this we join:
- CUSTOMER.ID to SOHEADER.DEBITOR
- SOHEADER.NUMBER to SOITEM.PO
- SOITEM.ARTICLE to ARTICLE.PART
In addition we activate (marked with an Orange light):
- CUSTOMER.NAME
- CUSTEOMER.SEGMENT
- SOHEADER.TOTAL
- ARTICLE.CATEGORY
To finish our vocabulary, we create an Output Type:
Now we got the basis to create our first HANA Rule. In the Fiori Launch Pad of the SAP HANA Rules Framework chose Rules – Mange all rules and create a new HANA Rule:
Then add the following conditions. Type forward help will help you immensely with this, especially for the joined condition Category over three intermediate tables:
Finally Add Output Customer and provide conditions as follows:
- Conditions: SEGMENT of the CUSTOMER = ‘Y’
- CATEGORY of the PART of the PO of the DEBITOR of the CUSTOMER = ‘G’
- Outputs: Customer NAME of the CUSTOMER
Now Activate the Rule and select Rule Services from the Fiori Launch Pad of the SAP HANA Rules Framework and create a new Rules Service as follows:
Once you save this Rule Service and Test run it, you get two hits as expected, i.e. the customers in Segment = 'Y' and at least one purchase of a product in Category = 'G':
Now you can play with the Rule Conditions and check-out the respective Test Results. If you for example changed the Category Condition to ‘P’ and Activate it:
You would only get the one expected Test Result back:
And when further changing the Segment Condition to ‘X’ and Activate it:
You get back the one customer with Segment = ‘X’ and a product in Category = ‘P’:
Appendix
These are the SQL scripts to create the Point of Sales data model used in this blog. Schema USER will have to be replaced with your user schema:
CREATE COLUMN TABLE "USER"."CUSTOMER" ("ID" INTEGER CS_INT,
"NAME" VARCHAR(8),
"SEGMENT" VARCHAR(1),
PRIMARY KEY ("ID")) UNLOAD PRIORITY 5 AUTO MERGE
insert into "USER"."CUSTOMER" values(1,'Faigle','Y')
insert into "USER"."CUSTOMER" values(2,'Frehn','X')
insert into "USER"."CUSTOMER" values(3,'Schuler','Y')
CREATE COLUMN TABLE "USER"."SOHEADER" ("NUMBER" INTEGER CS_INT,
"DEBITOR" INTEGER CS_INT,
"TOTAL" DECIMAL(5,
2) CS_FIXED,
PRIMARY KEY ("NUMBER")) UNLOAD PRIORITY 5 AUTO MERGE
insert into "USER"."SOHEADER" values(1,1,70)
insert into "USER"."SOHEADER" values(2,2,50)
insert into "USER"."SOHEADER" values(3,3,30)
CREATE COLUMN TABLE "USER"."SOITEM" ("PO" INTEGER CS_INT,
"ARTICLE" INTEGER CS_INT,
"COUNT" INTEGER CS_INT,
"AMOUNT" DECIMAL(5,
2) CS_FIXED) UNLOAD PRIORITY 5 AUTO MERGE
insert into "USER"."SOITEM" values(1,1,1,50)
insert into "USER"."SOITEM" values(1,2,2,20)
insert into "USER"."SOITEM" values(2,1,1,50)
insert into "USER"."SOITEM" values(3,2,3,30)
CREATE COLUMN TABLE "USER"."ARTICLE" ("PART" INTEGER CS_INT,
"DESCRIPTION" VARCHAR(10),
"PRICE" DECIMAL(5,
2) CS_FIXED,
"CATEGORY" VARCHAR(1),
PRIMARY KEY ("PART")) UNLOAD PRIORITY 5 AUTO MERGE
insert into "USER"."ARTICLE" values(1,'Keyboard',50,'P')
insert into "USER"."ARTICLE" values(2,'USB Stick',10,'G')
Source: scn.sap.com
No comments:
Post a Comment