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 saw that introduction of Decision table in SAP HANA, is a begining of new radical approach to model decision table in database layer and consume in application based on the database. With this foundation, let us start from scratch as I will guide you how to create decision table with simple and easy steps.

Create Decision Table

  1. Start the HANA Studio
  2. Open Modeler perspective
  3. Add HANA system
  4. Expand HANA System/Content folder
  5. To create new package, select context menu option New/Package

         

               Figure 9.1 : Create package from context menu

   

  1. Give the name of the package as simple-decisiontable
  2. To create a new decision table,
    1. Select the package and click New / Decision Table
    2. Give the name of the decision table as SIMPLE
    3. Once the decision table is created, an editor opens

             

               Figure 9.2 : Create decision table from context menu

  1. In the Output panel (on the right), of the editor, select Parameters node
  2. To create new Parameter, right click and select New…

         

               Figure 9.3 : Create Parameters using context menu in Output panel

  1. In the Parameters dialog, enter
    1. Name as QUANTITY
    2. Data Type as INTEGER

 

         

               Figure 9.4 : Dialog to create new Parameter

  1. Repeat the above steps (8,9, and 10) to create two more parameters
    1. Name as ORDER_AMOUNT, Data type as Decimal (length as 10, Scale as 2)
    2. Name as DISCOUNT, Data type as Decimal (length as 3, scale as 2)

   

Model Decision Table

  1. To do so,
    1. Add QUANITY and ORDER_AMOUNT as Condition of the decision table
      1. Select QUANTITY under Parameters node in Output panel 
      2. Right click and select Add as Conditions option
      3. Repeat the step to add ORDER_AMOUNT as condition

                   

                   

                         Figure 9.5 : Adding Parameter as Condition of decision table using context menu


    1. Add DISCOUNT as Action of the decision table
      1. Select DISCOUNT under Parameters node in Output panel
      2. Right click and select Add as Actions option

                 

                    Figure 9.6 : Adding Parameter as Action of decision table using context menu

  1. Your decision table would finally look like

         

               Figure 9.7 : Decision table overview with Parameters added as Condition and Action

         

  1. Manually fill the decision table with values, by using right click options like Add Condition Values etc on the decision table editor

Figure 9.8 : Decision table populated with data

 


Validate and Activate Decision Table

  1. Save and Validate the decision table
    1. To do so, select Save and Validate button on top-right panel of the decision table editor

             

                    Figure 9.9 : Validate button to perform validate operation on decision table

   

  1. Activate the decision table
    1. To do so, select Save and Activate button on top right panel of decision table editor

               

                    Figure 9.10 : Activate button to perform activate decision table for consumption

                Hint: Check Job Log view are success or failure of Validate and Activate operations

               

                    Figure 9.11 : Job Log view showing succesful execution of validate and activate action

  1. Once Activated you can find the decision table runtime object, which is a procedure, at HANA System/Catalog/_SYS_BIC_/Procedures
    [ Note: The name of the procedure will be <package-name>/decisiontable-name> i.e. simple-decisiontable/SIMPLE]

     Figure 9.12 : Decision table procedure generated after activation

Consume Decision Table

  1. Open the procedure definition by,
    1. Option 1 : Double click on the procedure
    2. Option 2 : Right click on procedure and select Open Definition option
    3. Note the IN and OUT parameters

       

               Figute 9.13 : Decision table procedure definition

     

  1. Open the SQL Editor
  2. Write the SQL statement to call the decision table procedure

    call "_SYS_BIC"."simple-decisiontable/SIMPLE" (40, 300000, ?)  

        [ Note that 40 is entered as IN parameter value for QUANTITY, similarly 300000 is entered as IN parameter value for ORDER_AMOUNT, ? in entered for OUT parameter ]

  1. Execute the SQL statement by selecting the Execute button on top right of the SQL Editor

Figure 9.14: Exeucte button in SQL Editor

  1. The result could be seen as

         

               Figure 9.15 : Result view after execution of decision table procedure

Analyse Decision Table Execution

Here you see how the evaluation of the decision table happened for input value of QUANTITY and ORDER_AMOUNT to return the value of DISCOUNT as 10

          Figure 9.16: Decision table exeuction trace

Having seen how to model decision table and consume the results in your application, you can start using this new capability of business rules management in SAP HANA and let us know of your use cases where we can support you. Me and my team would be happy to help you !

Other Related Blogs

12 Comments