Dynamic Database View Capability of SAP NetWeaver Decision Service Management
October 2013 Dynamic Database View Capability of SAP NetWeaver Decision Service Management
2 TABLE OF CONTENTS
USE CASE ........................................................................................................................................................ 4 USING DYNAMIC DATABASE VIEWS IN SAP NETWEAVER DECISION SERVICE MANAGEMENT ........ 6 HANA Result View ........................................................................................................................................... 6 Calculated Fields ........................................................................................................................................... 21 Input Parameters ........................................................................................................................................... 30 SAP HANA DATABASE INTEGRATION ....................................................................................................... 36 Automatically generated objects ................................................................................................................. 36 Generating reusable objects ........................................................................................................................ 38
Dynamic Database View Capability of SAP NetWeaver Decision Service Management 3 Dynamic Database View is a capability of SAP NetWeaver Decision Service Management to integrate with HANA databases. A deployment of a Dynamic Database View to the HANA database generates an SQL procedure with result view based on database (tables, views) and Decision Table content. The code push down to the HANA database allows the decision service logic to access HANA database tables directly, providing for significantly improved performance compared to classical rules execution logic. Tests with more than 1600.000 database records and decision tables with more than 5000 lines revealed that the Dynamic Database View is more than 1300 times faster than the classical approach in these constellations. Instead of more than 1.5 hours of processing time the rules were executed within 4 seconds. This gives room to a completely new area of use cases. The tremendous performance gain is mainly achieved by leveraging the HANA multi-core in memory processing architecture. In addition to this effect time and memory consuming data copies to the ABAP server can be avoided, if selections on calculated result columns are defined. With this paper we want to provide a hands-on guide to use Dynamic Database View. To focus on this capability we assume general knowledge of SAP NetWeaver Decision Service Management. For general information on SAP NetWeaver Decision Service Management, check out SAP Community Network (http://scn.sap.com/docs/DOC-29158). Especially refer to paper Social Benefit Determination with SAP NetWeaver Decision Service Management (https://scn.sap.com/docs/DOC-40949) which shows step by step how to create decision services, including all steps that were skipped in this publication.
Figure 1: Dynamic Database View overview Dynamic Database View Capability of SAP NetWeaver Decision Service Management 4 USE CASE We are using an example to read flight costs from a HANA database table, and to calculate deductions based on specific criteria, e.g. airline and connection, and variants submitted as input parameters. To do so we will create a BRFplus application. This is a container for all other objects. These objects contain the Function which is the actual decision service to be called, the Ruleset assigned to the Function containing all rules, a Database Lookup which is called within a rule, invoking the Dynamic Database View which accesses the HANA database, a Decision Table that is used within the Dynamic Database View to calculate additional fields, and input parameters that are being used within the Decision Table for evaluating conditions. Figure 2: Object relations Assogned Application
Function
Ruleset
Rule
Database Lookup
Dynamic Database View Decision Table Input Parameter HANA Database Assigned B e i n g
U s e d
Access Dynamic Database View Capability of SAP NetWeaver Decision Service Management 5 In this example we use table SFLIGHT of HANA Database ALX_2 to look up the price of specific flights. For instance flight AA0017 costs $488.36.
Figure 3: Table SFLIGHT In a second step we add deductions for specific flights. These deductions are derived by using a Decision Table adding calculated fields to all lines of the result table. So for instance there is discount of 10% for flight AA0017. Calculated fields allow for extending each line of the result view by fields that are not read from the HANA database table, but determined by a Decision Table. In the third step we use input parameters to refine the derivation of calculated fields. Actually we offer deductions depending on variants, which could be customer segments for instance. The flight mentioned before is discounted by 10% in variant 1, and 20% in variant 2. So calculated fields are not based on data from the HANA database table only, but also on data elements which can be input parameters of a Decision Service, or being determined by other business rules.
Dynamic Database View Capability of SAP NetWeaver Decision Service Management 6 USING DYNAMIC DATABASE VIEWS IN SAP NETWEAVER DECISION SERVICE MANAGEMENT HANA Result View As a first step we want to build a simple read operation from a HANA database table. We already created an application with a function and an assigned ruleset, which is still empty. The function has an input parameter VARIANT which will be used later.
Figure 4: Function Dynamic Database View Capability of SAP NetWeaver Decision Service Management 7 To connect the application with a HANA database, in the application we chose tab Miscellaneous and select a database connection.
Figure 5: Connect the application with HANA database By doing so all Dynamic Database Views contained in this application will connect to the selected HANA database for data access.
Figure 6: HANA database connected to all decision services within this application Dynamic Database View Capability of SAP NetWeaver Decision Service Management 8 If the system is running itself on a HANA database the database connection Default can be chosen to connect to this database.
Other database connections are being maintained with transaction DBCO, which allows managing connection information and connection options.
Figure 7: Transaction DBCO to manage HANA database connections Dynamic Database View Capability of SAP NetWeaver Decision Service Management 9 For each database connection all required information and authentication can be maintained.
Figure 8: Details of a database connection Let us go back to the decision service. In the yet empty ruleset create a rule processing a Database Lookup expression.
Figure 9: Create a Database Lookup expression Dynamic Database View Capability of SAP NetWeaver Decision Service Management 10 In this Database Lookup, instead of entering an ABAP database table, create a new Dynamic Database View, which will read directly from the HANA database.
Figure 10: Create new Dynamic Database View Dynamic Database View Capability of SAP NetWeaver Decision Service Management 11 As any other object Dynamic Database Views have technical names, short texts, and long texts.
Figure 11: Providing name and description for Dynamic Database View Dynamic Database View Capability of SAP NetWeaver Decision Service Management 12 In the Dynamic Database View we need to select a HANA view type consisting of database object, name and schema. For this example we use object type table. Then we identify the HANA view we want to access by selecting table name and database schema. After pressing Apply we can add result view fields.
Figure 12: Define HANA view and add result view fields Dynamic Database View Capability of SAP NetWeaver Decision Service Management 13 For our example we select the fields carrier id, connection id, and price.
Figure 13: Selecting fields Dynamic Database View Capability of SAP NetWeaver Decision Service Management 14 The result table of the Database Lookup can be created automatically from the Dynamic Database View. You only need to select the required fields, and enter names and texts for the table and the line structure.
Figure 14: Automatically create result table from Dynamic Database View Dynamic Database View Capability of SAP NetWeaver Decision Service Management 15
Figure 15: Select required fields Dynamic Database View Capability of SAP NetWeaver Decision Service Management 16
Figure 16: Enter names and texts for generated objects Dynamic Database View Capability of SAP NetWeaver Decision Service Management 17 We go back to the Database Lookup. If needed you can add selection conditions and adapt the field mapping which is being provided automatically.
Figure 17: Add selection condition and adapt field mapping Dynamic Database View Capability of SAP NetWeaver Decision Service Management 18 Now as the result table is created we can set it as result data object of the decision service.
Figure 18: Set result data object of function Dynamic Database View Capability of SAP NetWeaver Decision Service Management 19
Figure 19: Decision service with set result data object Dynamic Database View Capability of SAP NetWeaver Decision Service Management 20 After activating all objects we can process the decision service. We do so using simulation.
Figure 20: Activate objects and start simulation As a result we get all entries from the Dynamic Database View that match the given selection criteria.
Figure 21: Result the decision service provides Dynamic Database View Capability of SAP NetWeaver Decision Service Management 21 Calculated Fields Next we want to extend this example by adding a calculated field that is being determined by a decision table. Calculated fields allow to add values to each line of the result of a Dynamic Database View determined by Decision Tables. First we need to extend the line structure of the result table by the field that shall be calculated.
Figure 22: Add new data element to line structure of result table
Figure 23: Extended structure Dynamic Database View Capability of SAP NetWeaver Decision Service Management 22 In the Dynamic Database View, tab Calculated Columns, add the newly defined element DEDUCTION as result data object.
Figure 24: Add result data object Dynamic Database View Capability of SAP NetWeaver Decision Service Management 23 Now create a Decision Table to evaluate deductions.
Figure 25: Create Decision Table Dynamic Database View Capability of SAP NetWeaver Decision Service Management 24 In the following popups enter names and texts for the automatically generated result structure and the Decision Table itself.
Figure 26: Naming the result structure of the Decision Table Dynamic Database View Capability of SAP NetWeaver Decision Service Management 25
Figure 27: Naming the Decision Table In the Decision Table we need to call Table Settings to define condition columns.
Figure 28: Use Table Settings Dynamic Database View Capability of SAP NetWeaver Decision Service Management 26 As condition columns add carrier id and connection id.
Figure 29: Add condition columns Dynamic Database View Capability of SAP NetWeaver Decision Service Management 27 Now we can create lines to determine deductions for specific airlines and connections.
Figure 30: Fill Decision Table with content Dynamic Database View Capability of SAP NetWeaver Decision Service Management 28 In the Dynamic Database View we need to assign the data elements used in condition columns of the decision table to match the database fields of the Dynamic Database View.
Figure 31: Assign condition columns Dynamic Database View Capability of SAP NetWeaver Decision Service Management 29 Again we can activate all objects and simulate the decision service. As a result we get the same information as before, plus an entry specific deduction.
Figure 32: Result of the decision service including deduction Dynamic Database View Capability of SAP NetWeaver Decision Service Management 30 Input Parameters Now we want to use input parameters that contribute to the calculated fields in the result view. For that purpose the decision service has an input parameter VARIANT as we noticed before. To make use of that parameter, press Add Data Object in the Dynamic Database View, tab Input Parameters, and add data element VARIANT as an input parameter.
Figure 33: Result of the decision service including deduction Dynamic Database View Capability of SAP NetWeaver Decision Service Management 31 Add data element VARIANT as an additional condition column to the Decision Table and maintain its content accordingly to reflect different deductions for different variants.
Figure 34: Adding condition column VARIANT to the Decision Table Dynamic Database View Capability of SAP NetWeaver Decision Service Management 32 In the Database Lookup you need to assign the input parameter mapping, to map context parameters to respective input parameters.
Figure 35: Input parameter mapping Dynamic Database View Capability of SAP NetWeaver Decision Service Management 33
Figure 36: The Database Lookup with parameter mapping Dynamic Database View Capability of SAP NetWeaver Decision Service Management 34 Again activate all objects and simulate the decision service. This time you need to enter a value for input parameter variant.
Figure 37: Enter value for input parameter Variant With variant V1 the result is the exact same as before.
Figure 38: Result of the decision service with variant V1 Dynamic Database View Capability of SAP NetWeaver Decision Service Management 35 Doing the same with variant V2 results in changed deduction values.
Figure 39: Result of the decision service with variant V2 Dynamic Database View Capability of SAP NetWeaver Decision Service Management 36 SAP HANA DATABASE INTEGRATION Automatically generated objects Those readers who are interested in technical backgrounds can find some information on HANA database integration in this section. For each Dynamic Database View with calculated columns a Decision Table is generated in the Content area of the SAP HANA Studio. It can be found in package system-local.abap.<SYSID>.BRFplus.
Figure 40: Package for the automatically generated decision table in the SAP HANA Studio
Figure 41: Content of the generated decision table in the SAP HANA Studio
Figure 42: Data foundation of the generated decision table in the SAP HANA Studio Dynamic Database View Capability of SAP NetWeaver Decision Service Management 37 For the runtime execution of this Decision Table an SQL script procedure is being generated in the Catalog area of the SAP HANA Studio under schema _SYS_BIC.
Figure 43: Schema for the generated SQL procedure in the SAP HANA Studio
Figure 44: SQL script coding for the generated SQL procedure in the SAP HANA Studio The generated objects will be replaced automatically by new objects when they get obsolete due to changes in the decision service. The old obsolete objects will then be removed automatically after some time. Thus they must not be referred to directly by other objects in the HANA layer. Table FDT_CC_H_0000 defines the mapping between the Dynamic Database View GUID and the generated names for the Decision Tables and Database SQL Procedures in the SAP HANA Studio. Dynamic Database View Capability of SAP NetWeaver Decision Service Management 38 Generating reusable objects A reusable Decision Table in Rules on HANA can be generated for a Dynamic Database View with report FDT_HANA_DT_CREATE_FROM_DDBV.
Figure 45: Selection screen of report FDT_HANA_DT_CREATE_FROM_DDBV . Figure 46: The generated reusable decision table in the SAP HANA studio
2013 SAP AG. All rights reserved. SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP BusinessObjects Explorer, StreamWork, SAP HANA, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries. Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Business Objects Software Ltd. Business Objects is an SAP company. Sybase and Adaptive Server, iAnywhere, Sybase 365, SQL Anywhere, and other Sybase products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Sybase Inc. Sybase is an SAP company. Crossgate, m@gic EDDY, B2B 360, and B2B 360 Services are registered trademarks of Crossgate AG in Germany and other countries. Crossgate is an SAP company. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.