|
| 1 | +--- |
| 2 | +title: Creating a Graphical Calculation View |
| 3 | +description: Creating a Graphical Calculation View with a Dimension data type |
| 4 | +tags: [ tutorial>intermediate, topic>sql, products>sap-hana, products>sap-hana,-express-edition ] |
| 5 | +--- |
| 6 | +## Prerequisites |
| 7 | + - **Proficiency:** Intermediate |
| 8 | + - **Tutorials:** [Creating an HDI Module](http://go.sap.com/developer/tutorials/xsa-hdi-module.html) |
| 9 | + |
| 10 | +## Next Steps |
| 11 | + - [Creating a Calculation View with a Cube data type and Star Join](http://go.sap.com/developer/tutorials/xsa-sqlscript-cube.html) |
| 12 | + |
| 13 | +## Details |
| 14 | +### You will learn |
| 15 | +You will learn about creating a graphical calculation views with dimension data. |
| 16 | + |
| 17 | +### Time to Complete |
| 18 | +**15 Min**. |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | +1. Before you start creating Calculation views, you will want to import a larger database module than you care to create by hand. Right mouse click on the `db/src/data` folder and choose Import -> From File System. |
| 23 | + |
| 24 | +  |
| 25 | + |
| 26 | +2. Choose the file `data.zip` from the Download folder of your local client machine. Keep all other parameters the same. Press OK. Confirm that it is OK to overwrite the existing files. If the file is not available please check our GIT repository. |
| 27 | +  |
| 28 | +  |
| 29 | + |
| 30 | +3. Now that you have your database development objects, you are ready to build the module which will create them in the HANA database. This process technically executes a Node.js application which will call over to HANA and deploy these database artifacts into their container. Right mouse click on the db folder and choose *Build*. |
| 31 | +  |
| 32 | + |
| 33 | +4. Similar to the run activity of the web module earlier; the status of the build will be displayed in a window in the lower right side of the IDE. If everything worked correctly, you should see that the build completed successfully. |
| 34 | +  |
| 35 | +5. There is a new database tool called the HANA Runtime Tools (or HRTT) that can be used to view and interact with HDI created content. Open a new browser tab and navigate to `https://<hostname>:51006` to access this tool. |
| 36 | +  |
| 37 | +6. You can explore some of the new tables and their content that have been imported. This is the SHINE (SAP HANA Interactive Education) content. |
| 38 | +  |
| 39 | + 7. Now you are ready to create our calculation views. From the `db/src` folder, right click and choose “New”, then “Folder”. |
| 40 | +  |
| 41 | +8. Enter the name of the folder as “models” and click “OK”. |
| 42 | +  |
| 43 | +9. In the models sub-folder of your project, create a new calculation view based upon the expanded information for the products. This will require joining the products, texts, `businessPartner`, and address tables. Right mouse click on the models package, choose New -> Calculation View |
| 44 | +  |
| 45 | +10. Enter the name as PRODUCTS and a Label of Products View. Choose DIMENSION as the data category. A DIMENSON Calculation View will be very similar to the older Attribute View – A basic join with no aggregation. Click “Create”. |
| 46 | +  |
| 47 | +11. You want to join several tables from our project. Ultimately you will join `MD.Products`, `MD.BusinessPartner`, `MD.Addresses` and `Util.Texts` (twice). In order to do so we have to create a join node for each join criteria. Start by creating a Join Node pressing the Create Join button. |
| 48 | +  |
| 49 | + |
| 50 | +12. As we have several joins to add drag this new join node down near the bottom of the design window. |
| 51 | + |
| 52 | +  |
| 53 | + |
| 54 | +13. Click on the node and rename it to `Product_BP`. |
| 55 | + |
| 56 | +  |
| 57 | + |
| 58 | +14. Press the Plus button next to the node to add `tables/views` to the join node. |
| 59 | + |
| 60 | +  |
| 61 | + |
| 62 | +15. Add `MD.Products` to the node. |
| 63 | + |
| 64 | +  |
| 65 | + |
| 66 | +16. Repeat the process and add `MD.BusinessPartner` to the node. |
| 67 | + |
| 68 | +  |
| 69 | + |
| 70 | +17. We now want to create a join between the two tables on the `SUPPLIER.PARTNERID` to the `PARTNERID` column. Drag and drop to connect the two columns in the Join Definition. |
| 71 | + |
| 72 | +  |
| 73 | + |
| 74 | +18. Switch to the Mapping tab. We can then select which columns we want from this part of the join. ``` Select PRODUCTID, TYPECODE, CATEGORY, CURRENCY, PRICE, NAMEID, DESCID, PARTNERID, COMPANYNAME,and ADDRESES.ADDRESSID and then choose Add To Output. ``` |
| 75 | +  |
| 76 | + |
| 77 | +14. Optionally, you can change the name of a column as it becomes part of the view. For example you might change CATEGORY to `ProductCategory`. |
| 78 | + |
| 79 | +  |
| 80 | + |
| 81 | +15. Repeat the process of adding a Join Node. Name this new Join Node Address and connect the output `Product_BP` to this new join node. |
| 82 | + |
| 83 | +  |
| 84 | +  |
| 85 | + |
| 86 | +16. Add the `MD.Addresses` table to this join node. |
| 87 | + |
| 88 | +  |
| 89 | + |
| 90 | +17. Create a join between the `ADDRESSES_ADDRESSID` of the previous join node output and the `ADDRESSID` column of the `MD.Addresses` table. |
| 91 | + |
| 92 | +  |
| 93 | + |
| 94 | +18. Repeat the process of adding columns to the output. Select all columns from the `Product_BP` node except `ADDRESSES_ADDRESSID`. From The `MD.Addresses` table select CITY, POSTALCODE, STREET, BUILDING, COUNTRY, and REGION. |
| 95 | + |
| 96 | +  |
| 97 | + |
| 98 | +19. Repeat the process of adding a Join Node. Name this new Join Node `Product_Name` and connect the output Address to this new join node. |
| 99 | + |
| 100 | +  |
| 101 | + |
| 102 | +20. Add the `Util.Texts` table to this join node. |
| 103 | + |
| 104 | +  |
| 105 | + |
| 106 | +21. Create a join between the `NAMEID` of the previous join node output and the `TEXTID` column of the `Util.Texts` table. |
| 107 | + |
| 108 | +  |
| 109 | + |
| 110 | +22. In the Join Properties window, change the Join Type to Text Join and the Language Column to LANGUAGE. |
| 111 | + |
| 112 | +  |
| 113 | + |
| 114 | +23. Repeat the process of adding columns to the output via the mapping tab. Select all columns from the Address node except `NAMEID`. From the `Util.Texts` table select TEXT but change the name of the TEXT column in the output to `ProductName`. |
| 115 | + |
| 116 | +  |
| 117 | + |
| 118 | +24. Repeat the process of adding a Join Node. Name this new Join Node `Product_Desc` and connect the output `Product_Name` to this new join node. |
| 119 | + |
| 120 | +  |
| 121 | + |
| 122 | +25. Add the `Util.Texts` table to this join node. |
| 123 | + |
| 124 | +  |
| 125 | + |
| 126 | +26. Create a join between the `DESCID` of the previous join node output and the `TEXTID` column of the `Util.Texts` table. |
| 127 | + |
| 128 | +  |
| 129 | + |
| 130 | +27. In the Join Properties window, change the Join Type to Text Join and the Language Column to LANGUAGE. |
| 131 | + |
| 132 | +  |
| 133 | + |
| 134 | +28. Repeat the process of adding columns to the output via the mapping tab. Select all columns from the `Product_Name` node except `DESCID`. From the `Util.Texts` table select TEXT but change the name of the TEXT column in the output to `ProductDesc` . |
| 135 | + |
| 136 | +  |
| 137 | + |
| 138 | +29. Connect the output of the `Product_Desc` node to the Projection node at the top of the design window. |
| 139 | + |
| 140 | +  |
| 141 | + |
| 142 | +30. In the Projection node and Mapping tab, press the Auto Map by Name button. |
| 143 | + |
| 144 | +  |
| 145 | + |
| 146 | +31. Select the Semantics node and choose the Columns tab. Select the Key column for PRODUCTID. |
| 147 | + |
| 148 | +  |
| 149 | + |
| 150 | +32. In the View Properties tab, change the Apply Privileges to the blank value. |
| 151 | + |
| 152 | +  |
| 153 | + |
| 154 | +33. Save your model |
| 155 | + |
| 156 | +  |
| 157 | + |
| 158 | +34. Build the `hdb` module and then return to the HRTT tool. Your container will now have an entry in the Column Views folder for this new Calculation View. |
| 159 | + |
| 160 | +  |
| 161 | + |
| 162 | +35. For an initial test make sure your output looks similar to the following: |
| 163 | + |
| 164 | +  |
| 165 | + |
| 166 | +## Next Steps |
| 167 | + - [Creating a Calculation View with a Cube data type and Star Join](http://go.sap.com/developer/tutorials/xsa-sqlscript-cube.html) |
|
0 commit comments