Skip to Content
Author's profile photo Archana Shukla

Step-by-Step Guide to model Simple Decision Table

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

          /wp-content/uploads/2013/10/9_2_299634.png

               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

              /wp-content/uploads/2013/10/9_3_299635.png

               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…

          /wp-content/uploads/2013/10/9_4_299639.png

               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

 

          /wp-content/uploads/2013/10/9_5_299640.png

               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

                   

                    /wp-content/uploads/2013/10/9_6_299641.png

                         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

                  /wp-content/uploads/2013/10/9_7_299642.png

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

  1. Your decision table would finally look like

          /wp-content/uploads/2013/10/9_8_299648.png

               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

/wp-content/uploads/2013/10/9_9_299644.png

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

              /wp-content/uploads/2013/10/9_12_299650.png

                    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

                /wp-content/uploads/2013/10/9_13_299651.png

                    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

                /wp-content/uploads/2013/10/9_14_299652.png

                    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]

/wp-content/uploads/2013/10/9_15_299653.png

     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

        /wp-content/uploads/2013/10/9_16_299654.png

               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

/wp-content/uploads/2013/10/9_17_299655.png

Figure 9.14: Exeucte button in SQL Editor

  1. The result could be seen as

          /wp-content/uploads/2013/10/9_18_299656.png

               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

/wp-content/uploads/2013/10/9_19_299666.png

          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

Assigned Tags

      12 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Shahid Mohammed Syed
      Shahid Mohammed Syed

      Thank You. This is Handy!

      Author's profile photo Former Member
      Former Member

      Helpful INFO, Thanks For Sharing

      Author's profile photo Former Member
      Former Member

      My first touch on HANA!  Thank you for the detailed step-by-step instructions.  Great for a newbie like me to follow!

      Author's profile photo CH Raman
      CH Raman

      Useful blog .Thanks sharing in detailed steps.

      Author's profile photo Krishna Chaitanya
      Krishna Chaitanya

      Good one..really you presented it in step by step.  Great Job.

      Author's profile photo Archana Shukla
      Archana Shukla
      Blog Post Author

      Hello Khalid,

      Where are you looking for the procedure ?

      (1) You must look the procedure in "_SYS_BIC" schema

      (2) Refresh the Procedure folder - refresh does not happen automatically if the folder is opened already.

      Regards,

      Archana

      Author's profile photo Khalid TAIBI
      Khalid TAIBI

      Hello Archana,

      Yes I looked in "_SYS_BIC" schema and I refreshed the procedure folder.

      When I tried to display the data preview of decision table I get the error message about roles user.

      I executed the Grant SQL instruction and now all it's OK.

      Thank you for your help.

      Author's profile photo Former Member
      Former Member

      Hello Archana,

      Nice Document. Step by step articulation is good .

      Regards,

      Prashanth Maturu

      Author's profile photo Former Member
      Former Member

      Hi Archana

      i have seen the Data foundation Node also while creating the decision Table (HANA SP09).

      Seems you have explained only decison Table node.

      Author's profile photo Archana Shukla
      Archana Shukla
      Blog Post Author

      Hello Manoj,
      This blog is targeted for decision tables based on Parameters. There is another blog in the series :Decision Table on HANA Database Tableswhere there is mention of Data Foundation. There are many ways in which you can model the decision table - based on the desired output. This is one of those flavors.

      Author's profile photo veda prabha
      veda prabha

       

      Hi Archana,

      Nice info, Thank you.

      Can you please answer how do Business users use this Decision table for their analysis?

      Do User need Eclipse?

      Thank you!

       

      Author's profile photo Archana Shukla
      Archana Shukla
      Blog Post Author

      Hello Veda,

      As mentioned in the blog, a SQL procedure gets generated when you activate the decision table. This procedure can be consumed in any application to run the rules. you can also create HANA xs service to run the rules, and then give that service to your business user to consume rules.

      Regards,
      Archana