Skip to Content

How to Write a Script based Calculation View?

This is one of the ways of creating a calculation view that is based on a script

Step 1) Create a new calculation view and select subtype to be “SQL Script” ( other option is Graphical)

2014-08-20 10_43_33-SAP HANA Modeler - sial.sapnext.usr.mshort.ZEHS_CA_PRODUCT DRP (ARAMACHA)  - SAP.jpg

Step 2)

Insert the code as shown below

/********* Begin Procedure Script ************/


  var_out = SELECT “MaterialOldID” as “Product”,

                   COUNT(*) as “Materials”

    FROM “_SYS_BIC”.”sap.hba.ecc/Material”

    GROUP BY “MaterialOldID”;

END /********* End Procedure Script ************/

Please note you will have to define the columns and the column meta data

In this example we have defined two output columns



Important Consideration

Please note that though it is convenient to write a calculation view based on a script there are consideration for aggregation and calculation columns you have to consider the implication of further usage of the calculation view.

if you script has complex calculated columns one needs to be aware of the formula and how it will be summed up if it is used for some other views

Another hint is to use SQL script as a means to create INLINE tables and this gives you a lot of flexibility in doing the modelling.

Avoid using SELECT * FROM always as that will be a not very efficient


Be the first to leave a comment
You must be Logged on to comment or reply to a post.