Professional Documents
Culture Documents
SAP HANA Rules Framework 1.0 SPS08 Modeling Guide
SAP HANA Rules Framework 1.0 SPS08 Modeling Guide
1 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 Modeling a Vocabulary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1 Adding Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 Adding Columns as Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Creating an Association. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.4 Creating Actions in the Vocabulary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7
2.5 Creating a Reusable Output Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.6 Activating a Vocabulary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.7 Extending a Predelivered Vocabulary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
This change log is a record of additions and major changes to the SAP HANA Rules Framework Modeling Guide
since the previous support package stack (SPS). Where applicable, each item links to the topic concerned.
Tip
For further information about all the additions and changes in this release, including patch level releases,
refer to SAP Note 2332946 .
July 14, 2016 As of this release, you can only add attributes to condition columns by choosing Add in the context
Doc. v1.0 menu of the Condition Columns node.
See: Adding Attributes to Condition Columns [page 13]
This guide describes modeling resources for SAP HANA rules framework using SAP HANA studio. SAP HANA
rules framework provides a set of tools that allows end users to build decision logic based on data of an
organization.
Target Audience
This guide is intended for solution experts and application developers to execute the following tasks:
● Modeling vocabulary
● Modeling two types of rules such as rules of decision table type and IF-THEN type
These are the set of tools that are a part of SAP HANA studio. These tools enable solution experts and
application developers to create rule based applications, which includes modeling predefined content as part
of the application. For more information about various resources supported by SAP HANA rules framework,
see SAP HANA Rules Framework Development & Implementation Guide .
Business Scenarios
You use rules of decision table type for the tabular representation of business logic. Transactions like online
shopping for example require application of rules in tabular form. You use rules of IF-THEN type for the textual
representation of business logic. For example, you use text-based representation of rules in frequent car
insurance claims.
● You must install the SAP HANA rules framework modeling tools to get started with the modeling.
For more information on installation, see the Deploying the SAP HANA Rules Framework Modeling Tools
(Optional) section in the SAP HANA Rules Framework Installation & Upgrade Guide on SAP Service
Marketplace on http://service.sap.com/%7Eform/sapnet?_SHORTKEY=00200797470000103845 .
● You are granted the sap.hrf::ReadAnyVocabulary application privilege to use the SAP HANA rules
framework modeling tools.
You use a vocabulary to express the business logic either with the rule expression language, or with the
selection of actions and outputs to be performed.
Context
A vocabulary defines the data model that you share across different rule artifacts. It acts as the semantic layer
that describes the data model, actions, and output structure that you use in the application. Typically, an
application contains different vocabularies.
For more information about vocabularies, see SAP HANA Rules Framework Development & Implementation
Guide .
Procedure
5. In the wizard, choose SAP HANA Application Development Rules Framework Vocabulary .
6. Choose Next.
7. In Create New Rule Vocabulary, browse to select a project.
8. Enter a name and description.
9. Choose Finish.
Scope Description
You add tables to use the table columns as data objects while modeling a vocabulary.
Procedure
● If you want to add physical tables, go to the Project Explorer tab and drag the required tables from
Catalog Tables to the Data Foundation node.
Note
Alternatively, you can add tables using the below steps:
1. Select the Data Foundation node.
● If you want to add information views, go to the Systems tab and drag the required information views by
choosing a Package Content .
You add columns as attributes to connect the actual data to the attributes.
Procedure
1. In the Details pane of the Data Foundation node, select the required table column.
2. In the context menu of the required column, choose Add as Attribute.
Note
○ The Vocabulary node in the Outline pane is hierarchical in structure. The first level of hierarchy is
the data object. This data object consists of tables or views. The next levels are attributes and
associations that you use to build the rule condition expressions.
○ You can add multiple columns at the same time.
○ If you want to delete attributes from the Attributes node, select an attribute and in its context menu,
choose Remove.
You use associations to relate various data objects, and to enable rule expressions to navigate from a source
data object to an attribute of the target data object.
Procedure
Note
You can also link multiple attributes.
f. Choose OK.
5. To edit the composite association, choose Edit in the context menu of the required association.
6. To delete the composite association, choose Delete in the context menu of the required association.
You create an action that the system executes upon successful evaluation of a condition.
Context
The example given below explains the action performed on evaluation of a condition.
Procedure
Note
The XSJS library needs to have a HANA rules framework specific function. For more information, see
“Consuming a Rule Service” in the SAP HANA Rules Framework Development & Implementation Guide
5. Choose OK.
6. In the Action Parameters section, choose Add.
7. Provide parameter details.
8. In the Static Action Parameters section, choose Add.
Results
You use this procedure to define output types in vocabulary, which you reuse across different rules. After
adding them as a rule output through the rules editor, they contain the results of the rule execution.
Procedure
7. Select the icon, which displays all the expressions present in tables.
Note
You can also add complex expression to a static parameter.
8. Select the required Expression from the dropdown list to add them as Static Parameters.
9. Choose OK.
These attributes appear in the Output Types node.
Note
○ The hierarchy of the Output Types node is the name of the output followed by various parameters.
○ You create multiple outputs by following the same procedure.
Prerequisites
You have the runtime plug-in of SAP HANA rules framework active.
Note
The vocabulary must contain the extension .hprvocabulary.
Note
For more information about creating a rule using a vocabulary, see Modeling a Rule using Public
Vocabulary [page 12]
You can extend a predelivered application vocabulary with your own data objects, outputs, and action. This
extended vocabulary ensures all the entities from the reference vocabulary cannot be edited.
Procedure
1. If you want to consume a reference vocabulary within another vocabulary or a rule, then open the
vocabulary or rule where you want to consume a vocabulary.
2. Create a vocabulary that you want to consume.
3. Drag the created vocabulary from Project Explorer to the Data Foundation node.
○ If you are consuming a vocabulary in another vocabulary, then the reference vocabulary appears in
the Data Foundation node. The data objects of the referenced vocabulary appear in the Details pane,
Actions node and Output node. If the referenced vocabulary is itself referencing another vocabulary,
then all level data objects appear in the topmost reference.
○ If you are consuming a vocabulary in a rule, then the reference vocabulary appears in the Data
Foundation node. If the reference vocabulary contains a child vocabulary, then the tables from the
child vocabularies also appear in the Details pane and Outline pane.
4. In the context menu of the required vocabulary or rule in Project Explorer, choose Team Activate to
activate the vocabulary or rule respectively.
Note
○ The referenced vocabulary entities such as data objects, attributes, associations, actions, and
output types are not editable. However, you can add these elements as conditions and outputs.
Related Information
A decision table rule is a tabular representation of business logic containing a set of related input conditions
and output expressions.
Rules capture complex business logic in the form of business conditions and results. For example, formulating
business rules that calculate discount on the orders based on region and sales. Rules return results if they
satisfy the conditions defined in them. These results are in the form of simple structured output or of an
executable XSJS action. SAP HANA rules framework currently provides two models to define decision logic,
one of which is a decision table-based rule.
You use this procedure to model rules using a predefined vocabulary. After evaluation against live data, these
rules lead to a decision.
Prerequisites
You have created an active vocabulary. See Modeling a Vocabulary [page 5].
Procedure
5. In the wizard, choose SAP HANA Application Development Rules Framework Rule .
6. Choose Next.
7. In the Create New Rule dialog, and browse for a project.
8. Enter a name and description.
9. Select Decision Table as the Type.
10. Choose Finish.
You add attributes to condition columns as condition describes the rule whether or not to trigger any decision.
Procedure
Note
○ You can enter the attributes as an expression in the Expression field.
○ Content assist is available for adding expressions. This feature enables the selection and insertion
of existing code elements to complete partially entered code.
○ The expression that you provide should begin with the leading object notation in accordance with
Rule Expression Language. If you want to refer to the attribute of a non-leading object, then you
should use the following syntax: <Data Object Context/LeadingObject>.<Association
Name/Navigation Path>.<Target Attribute Name>
For example, consider Account(AccountNumber, AccountHolderName, Balance) and
Customer(CustomerName, CustomerAddress, CreditPoints) as two data objects of the vocabulary.
If “Account” is chosen as the Data Object Context (acting as the leading object) and that there is an
association between Account.AccountHolderName and Customer.CustomerName as "relation".
If you want to specify the following rule:
If Customer's Credit Points is greater than 500, then Account Balance should be redeemed with a
credit of 500 (current currency). This is modelled as
Sample Code
If
Account.relation.CreditPoints >500
Then
Account.Balance= Account.Balance+500;
○ An expression that does not follow the leading object notation should be updated manually, if it is
already consumed by an active rule.
3. Choose OK.
Note
○ To delete conditions, choose Remove from the context menu of the Condition Columns node in the
Outline pane.
Procedure
You reuse the output of vocabulary in the output of rule, which returns data upon successful evaluation of
condition.
Procedure
1. In the Outline pane, choose the Output Types that are in the vocabulary.
2. Right-click the Output Types that you want to use.
3. In the context menu of the required output type, select Add as Rule Output.
This output is displayed under Rule Output.
4. In the context menu of the required output in Rule Output, choose Edit.
5. You edit the parameters and static parameters in the Add Output window.
For more information about editing the Add Output, see Creating a Reusable Output Type [page 19].
6. Choose OK.
These attributes appear in the Rule Output node.
This procedure allows you to represent the business entities and define the working sets.
Context
● Data Object: This represents the business entity that you evaluate the rule on.
● Filter: This allows definition of the working sets.
● Input Parameters: You use them during the evaluation of data filtering condition. The following are the
three types of input parameters: scalar input parameters, hierarchical input parameters, and data objects.
Procedure
You use this procedure to provide a hierarchial structure for the input parameters.
Procedure
1. In the context menu of the Input Parameters node, choose Add Hierarchial Parameters.
2. In the Add Input Parameters window, provide the required details.
3. Provide name and description.
4. Choose Hierarchy Type to:
Note
Structure and Collection type of parameters need to have attributes in them.
Note
In the context menu of Input Parameters node, choose Edit to perform any editing.
Results
Procedure
1. In the context menu of the Input Parameters node, choose Add Scalar Parameters.
2. In the Add Input Parameters window, provide the required details.
3. Provide name and description.
4. In the Parameters section, choose Add upon adding each parameter.
5. Choose OK.
Note
In the context menu of Input Parameters node, choose Edit to perform any editing.
Results
You use this procedure to add the vocabulary data objects to the input parameters.
Procedure
1. In the context menu of the Input Parameters node, choose Add Data Objects.
2. In the Add Input Parameters window, provide name and description.
3. In the Data Object Name dropdown list, select the required data object.
4. In the Keys section, choose the data object that you want to set as key.
5. Choose OK.
Note
You can add data objects only if the input parameter does not contain any scalar parameters or
hierarchial parameters and vice-verse.
Results
Prerequisites
You have the runtime plug-in of SAP HANA rules framework active.
Procedure
1. In the Project Explorer view, choose the rule that you want to activate.
Note
The rule must contain the extension ".hprrule".
This procedure instructs you how to create a rule without using a public or embedded vocabulary.
Procedure
5. In the wizard, choose SAP HANA Application Development Rules Framework Rule .
6. Choose Next.
7. In the Create New Rule dialog, browse for the required project.
8. Enter a name and description.
9. Select Decision Table as the Type.
10. Choose Finish.
11. Perform the following steps:
Description Link
Add tables that you apply a rule for See Adding Tables [page 6].
Add various attributes as conditions See Adding the Attributes to Condition Columns [page 13].
Provide values for actions and conditions See Adding the Condition Values [page 14].
Add input parameters and filters See Working with the Execution Context [page 15].
This is a procedure to create an output for a rule. Output is the data that system returns when a rule satisfies a
condition.
Procedure
Note
○ The name and description of the output are set to the default value.
○ To remove any attributes, choose Remove.
6. Choose Add.
7. Select the icon, which displays all the expressions present in decision tables.
8. Select the required Attribute from the dropdown list.
9. Choose OK.
10. Choose OK in the Add Output window.
The attributes appear in the Output node.
Note
For information about generating a rule, see Activating a Rule [page 17].
You use this procedure to model a textual rule. IF-THEN rule is a textual representation of business logic
containing a single Boolean condition expression and its corresponding output expressions.
Prerequisites
You have created an active vocabulary. See Creating a Vocabulary [page 5].
Procedure
Description Link
Add actions to rule action See Reusing a Rule Action from Action [page 21]
Add output types to rule output See Adding a Rule Output from Vocabulary [page 14].
Add input parameters and filters See Working with the Execution Context [page 15].
You add conditions, as they describe the rule whether or not to trigger any decision. Conditions are Boolean
expressions defined using the rule expression language in a text format.
Procedure
Note
For information about generating a rule, see Activating a Rule [page 17].
Procedure
Note
If you want to edit the rule action, then choose Edit in the context menu of the required action under the
Rule Action node.
For more information on editing the actions, see Creating Actions in Vocabulary [page 7]
Coding Samples
Any software coding and/or code lines / strings ("Code") included in this documentation are only examples and are not intended to be used in a productive system
environment. The Code is only intended to better explain and visualize the syntax and phrasing rules of certain coding. SAP does not warrant the correctness and
completeness of the Code given herein, and SAP shall not be liable for errors or damages caused by the usage of the Code, unless damages were caused by SAP
intentionally or by SAP's gross negligence.
Accessibility
The information contained in the SAP documentation represents SAP's current view of accessibility criteria as of the date of publication; it is in no way intended to be
a binding guideline on how to ensure accessibility of software products. SAP in particular disclaims any liability in relation to this document. This disclaimer, however,
does not apply in cases of wilful misconduct or gross negligence of SAP. Furthermore, this document does not result in any direct or indirect contractual obligations of
SAP.
Gender-Neutral Language
As far as possible, SAP documentation is gender neutral. Depending on the context, the reader is addressed directly with "you", or a gender-neutral noun (such as
"sales person" or "working days") is used. If when referring to members of both sexes, however, the third-person singular cannot be avoided or a gender-neutral noun
does not exist, SAP reserves the right to use the masculine form of the noun and pronoun. This is to ensure that the documentation remains comprehensible.
Internet Hyperlinks
The SAP documentation may contain hyperlinks to the Internet. These hyperlinks are intended to serve as a hint about where to find related information. SAP does
not warrant the availability and correctness of this related information or the ability of this information to serve a particular purpose. SAP shall not be liable for any
damages caused by the use of related information unless damages have been caused by SAP's gross negligence or willful misconduct. All links are categorized for
transparency (see: http://help.sap.com/disclaimer).