├── .reuse └── dep5 ├── CONTRIBUTING.md ├── LICENSE ├── LICENSES └── Apache-2.0.txt ├── README.md └── exercises ├── ex0 ├── README.md ├── images │ ├── 01-InstallTemplates.png │ ├── 02-DownloadRawFile.png │ └── 03-RawDownload.png └── sources │ └── analytical_templates.xml ├── ex1 ├── README.md └── images │ ├── 01-EmbeddedAnalyticsInABAPCloud.png │ ├── 02-HandsOnScope.png │ └── 03-ADTDemoFlight.png ├── ex2 ├── README.md ├── images │ └── 01-RelationExplorer.png └── sources │ ├── ZDT187v_XX_Airline_Dim │ ├── ZDT187v_XX_Airport_Dim │ ├── ZDT187v_XX_Connection_Dim │ └── ZDT187v_XX_Flight_Cube └── ex3 ├── README.MD ├── images ├── 01-MultiDimensionalPreview.png └── 231018_Embedded-Analytics-for-TechEd_Ext.pdf └── sources └── ZDT187v_XX_Flight_Query /.reuse/dep5: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: teched2023-DT187v 3 | Upstream-Contact: ospo@sap.com 4 | Source: https://github.com/sap-samples/teched2023-DT187v 5 | Disclaimer: The code in this project may include calls to APIs (“API Calls”) of 6 | SAP or third-party products or services developed outside of this project 7 | (“External Products”). 8 | “APIs” means application programming interfaces, as well as their respective 9 | specifications and implementing code that allows software to communicate with 10 | other software. 11 | API Calls to External Products are not licensed under the open source license 12 | that governs this project. The use of such API Calls and related External 13 | Products are subject to applicable additional agreements with the relevant 14 | provider of the External Products. In no event shall the open source license 15 | that governs this project grant any rights in or to any External Products,or 16 | alter, expand or supersede any terms of the applicable additional agreements. 17 | If you have a valid license agreement with SAP for the use of a particular SAP 18 | External Product, then you may make use of any API Calls included in this 19 | project’s code for that SAP External Product, subject to the terms of such 20 | license agreement. If you do not have a valid license agreement for the use of 21 | a particular SAP External Product, then you may only make use of any API Calls 22 | in this project for that SAP External Product for your internal, non-productive 23 | and non-commercial test and evaluation of such API Calls. Nothing herein grants 24 | you any rights to use or access any SAP External Product, or provide any third 25 | parties the right to use of access any SAP External Product, through API Calls. 26 | 27 | Files: * 28 | Copyright: 2023 SAP SE or an SAP affiliate company and teched2023-DT187v contributors 29 | License: Apache-2.0 30 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## Code of Conduct 4 | 5 | All members of the project community must abide by the [SAP Open Source Code of Conduct](https://github.com/SAP/.github/blob/main/CODE_OF_CONDUCT.md). 6 | Only by respecting each other we can develop a productive, collaborative community. 7 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting [a project maintainer](.reuse/dep5). 8 | 9 | ## Engaging in Our Project 10 | 11 | We use GitHub to manage reviews of pull requests. 12 | 13 | * If you are a new contributor, see: [Steps to Contribute](#steps-to-contribute) 14 | 15 | * Before implementing your change, create an issue that describes the problem you would like to solve or the code that should be enhanced. Please note that you are willing to work on that issue. 16 | 17 | * The team will review the issue and decide whether it should be implemented as a pull request. In that case, they will assign the issue to you. If the team decides against picking up the issue, the team will post a comment with an explanation. 18 | 19 | ## Steps to Contribute 20 | 21 | Should you wish to work on an issue, please claim it first by commenting on the GitHub issue that you want to work on. This is to prevent duplicated efforts from other contributors on the same issue. 22 | 23 | If you have questions about one of the issues, please comment on them, and one of the maintainers will clarify. 24 | 25 | ## Contributing Code or Documentation 26 | 27 | You are welcome to contribute code in order to fix a bug or to implement a new feature that is logged as an issue. 28 | 29 | The following rule governs code contributions: 30 | 31 | * Contributions must be licensed under the [Apache 2.0 License](./LICENSE) 32 | * Due to legal reasons, contributors will be asked to accept a Developer Certificate of Origin (DCO) when they create the first pull request to this project. This happens in an automated fashion during the submission process. SAP uses [the standard DCO text of the Linux Foundation](https://developercertificate.org/). 33 | 34 | ## Issues and Planning 35 | 36 | * We use GitHub issues to track bugs and enhancement requests. 37 | 38 | * Please provide as much context as possible when you open an issue. The information you provide must be comprehensive enough to reproduce that issue for the assignee. 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LICENSES/Apache-2.0.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![REUSE status](https://api.reuse.software/badge/github.com/SAP-samples/teched2023-DT187v)](https://api.reuse.software/info/github.com/SAP-samples/teched2023-DT187v) 2 | 3 | # DT187v - Build Analytical Applications with ABAP Cloud 4 | 5 | ## Description 6 | 7 | This repository contains the material for the SAP TechEd 2023 session called DT187v - Build Analytical Applications with ABAP Cloud.
8 | Watch the recording of the [Jump-Start Session: Build Analytical Applications with ABAP Cloud](https://go3.events.sap.com/sapteched/virtual/2023/reg/flow/sap/sapteched23/catalog/page/catalog/session/1693019886304001sNN4) to get an introduction ([slides of the Jump-Start Session](/exercises/ex3/images/231018_Embedded-Analytics-for-TechEd_Ext.pdf)). 9 | 10 | 11 | ## Overview 12 | 13 | This hands-on tutorial introduces attendees to building an analytical data model with ABAP Cloud that can be consumed by analytical applications like e.g., SAP Analytics Cloud. You will learn how to build analytical applications with the ABAP Cloud programming language using ABAP core data services, analytical providers and business services in the ABAP development tools. 14 | 15 | Specifically, you will build an analytical application, that uses SAP's Flight Demo Model. You will design the data model and the application in order to analyze the occupation of flights from different perspectives. 16 | 17 | While building the data model, you will be introduced to analytical terms like measures, dimensions, cubes and queries as well as to the general idea of analytical data modelling with the star schema.
18 | Previewing the analytical application and exploring its features will deepen this understanding. 19 | 20 | ## Requirements 21 | 22 | Experience in ABAP, ABAP CDS and working with the Eclipse based ABAP Development Tools (ADT) is recommended, but not strictly necessary. If you are in a hurry or find it hard to follow the instructions, intermediate and final solutions of the exercises are available ready to be copied & pasted (with low naming adaption effort). 23 | 24 | The hard [prerequisites](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex0/README.md) to follow the exercises in this repository are that you: 25 | 1) get a new trial account for the BTP ABAP environment (please make sure to get a new one if your account is older than 2023-10-15) 26 | 2) have the latest version of the ABAP development tools installed 27 | 3) have downloaded and installed the templates for analytical CDS views 28 | 29 | ## Exercises 30 | 31 | - [Prerequisites](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex0/README.md) 32 | - [Get a SAP BTP Trial Account](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex0/README.md#sap-btp-trial-account) 33 | - [Get the BTP ABAP Environment Trial](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex0/README.md#abap-environment-in-sap-btp-trial) 34 | - [Install Analytical CDS Templates](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex0/README.md#download-and-install-analytical-abap-cds-templates) 35 | 36 | - [Exercise 1 - Introduction to Analytics in ABAP Cloud](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex1/README.md) 37 | - [Exercise 1.1 - Read: Scope of the Tutorial](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex1/README.md#exercise-11---read-scope-of-the-tutorial) 38 | - [Exercise 1.2 - Read: Embedded Analytics in ABAP Cloud](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex1/README.md#exercise-12---read-embedded-analytics-in-abap-cloud) 39 | - [Exercise 1.3 - Hands-On: Use the FLIGHT Data Model for Analytics](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex1/README.md#exercise-13---hands-on-use-the-flight-data-model-for-analytics) 40 | - [Exercise 1 - Summary](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex1/README.md#summary) 41 | 42 | - [Exercise 2 - Build a Cube with Dimensions](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex2/README.md) 43 | - [Exercise 2.1 - Build the basic Cube](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex2/README.md#exercise-21---build-the-basic-cube) 44 | - [Exercise 2.2 - Prepare the Measures](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex2/README.md#exercise-22---prepare-the-measures) 45 | - [Exercise 2.3 - Prepare the Dimensions](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex2/README.md#exercise-23---prepare-the-dimensions) 46 | - [Exercise 2.4 - Use the Dimensions](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex2/README.md#exercise-24---use-the-dimensions) 47 | - [Exercise 2.5 - Optional - Add and use additional Dimensions](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex2/README.md#exercise-25---optional-add-and-use-additional-dimensions) 48 | - [Exercise 2 - Summary](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex2/README.md#summary) 49 | 50 | - [Exercise 3 - Build the analytical Query](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex3/README.MD) 51 | - [Exercise 3.1 - Build the initial query](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex3/README.MD#exercise-31---build-the-initial-query) 52 | - [Exercise 3.2 - Prepare the Measures](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex3/README.MD#exercise-32---prepare-the-measures) 53 | - [Exercise 3.3 - Working Multi-Dimensional](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex3/README.MD#exercise-33---working-with-the-multi-dimensional-analysis) 54 | - [Exercise 3 - Summary](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex3/README.MD#summary) 55 | 56 | 57 | **IMPORTANT** 58 | 59 | ## Contributing 60 | Please read the [CONTRIBUTING.md](./CONTRIBUTING.md) to understand the contribution guidelines. 61 | 62 | ## Code of Conduct 63 | Please read the [SAP Open Source Code of Conduct](https://github.com/SAP-samples/.github/blob/main/CODE_OF_CONDUCT.md). 64 | 65 | ## How to obtain support 66 | Support for the content in this repository is available during the respective [Jump-Start Session: Build Analytical Applications with ABAP Cloud](https://go3.events.sap.com/sapteched/virtual/2023/reg/flow/sap/sapteched23/catalog/page/catalog/session/1693019886304001sNN4) at Friday, November 3, 2023, 7pm CET, for which this content has been designed.
67 | Otherwise, you may request support via the [Issues](../../issues) tab.
68 | A [SAP Help page for Embedded Analytics in ABAP Cloud](https://help.sap.com/docs/abap-cloud/abap-analytics/abap-analytics) is available as well. 69 | 70 | ## License 71 | Copyright (c) 2023 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the [LICENSE](LICENSES/Apache-2.0.txt) file. 72 | -------------------------------------------------------------------------------- /exercises/ex0/README.md: -------------------------------------------------------------------------------- 1 | # Get Started 2 | 3 | In this exercise, you will create a trial user in the SAP BTP, ABAP Environment. 4 | 5 | ## SAP BTP Trial Account 6 | 7 | If you have not already done so you have first to register for the SAP BTP Trial [here](https://developers.sap.com/tutorials/abap-environment-trial-onboarding.html). 8 | 9 | ## ABAP Environment in SAP BTP Trial 10 | 11 | The steps to activate the ABAP Environment in the SAP BTP trial by creating an appropriate user are described in the following tutorial. 12 | 13 | If you already have an ABAP Environment Trial, please make sure to get a new one as the trial systgems have been updated for the TechEd 2023 sessions! 14 | 15 | [Create an SAP BTP ABAP Environment Trial User](https://developers.sap.com/tutorials/abap-environment-trial-onboarding.html) 16 | 17 | [Install ABAP Development Tools](https://developers.sap.com/tutorials/abap-install-adt.html) 18 | 19 | [Create ABAP Cloud Project](https://developers.sap.com/tutorials/abap-environment-create-abap-cloud-project.html) 20 | 21 | ## Download and install analytical ABAP CDS Templates 22 | 23 | As a first task we will start to import templates that we will use in this workshop to create Analytical CDS views such as dimension views, cubes and queries. 24 | 25 | **Step 1)** Click on the following link to display the file [analytical_templates.xml](https://github.com/SAP-samples/teched2023-DT187v/blob/main/exercises/ex0/sources/analytical_templates.xml)
26 | Then click the 'Download raw file' ![Download raw file icon](./images/03-RawDownload.png) button in the right upper corner to download **analytical_templates.xml**. 27 | 28 |
Click to expand!

29 | 30 | ![this is how](./images/02-DownloadRawFile.png) 31 | 32 |

33 | 34 | **Step 2)** In ABAP Development Tools, open the preferences and search for 'templates'. 35 | 36 | **Step 3)** In Data Definition Templates choose 'Import', then choose your file analytical_templates.xml.
37 |
Click to expand!

38 | 39 | ![this is how](./images/01-InstallTemplates.png) 40 | 41 |

42 | 43 | ## Summary 44 | 45 | Now that you have onboarded to the SAP BTP Trial, ABAP Environment and saved the analytical CDS templates, you can continue to - [Exercise 1 - Introduction to Analytics in ABAP Cloud](../ex1/README.md) 46 | -------------------------------------------------------------------------------- /exercises/ex0/images/01-InstallTemplates.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/teched2023-DT187v/e35519c03f0aaa8f8330e215079b1645d8145a5d/exercises/ex0/images/01-InstallTemplates.png -------------------------------------------------------------------------------- /exercises/ex0/images/02-DownloadRawFile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/teched2023-DT187v/e35519c03f0aaa8f8330e215079b1645d8145a5d/exercises/ex0/images/02-DownloadRawFile.png -------------------------------------------------------------------------------- /exercises/ex0/images/03-RawDownload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/teched2023-DT187v/e35519c03f0aaa8f8330e215079b1645d8145a5d/exercises/ex0/images/03-RawDownload.png -------------------------------------------------------------------------------- /exercises/ex0/sources/analytical_templates.xml: -------------------------------------------------------------------------------- 1 | 11 | 23 | 33 | 34 | -------------------------------------------------------------------------------- /exercises/ex1/README.md: -------------------------------------------------------------------------------- 1 | # Exercise 1 - Introduction to Analytics in ABAP Cloud 2 | 3 | In this exercise, you will understand what embedded analytics in ABAP Cloud is all about. 4 | Also, you will get to know the FLIGHT data model you will be working with. 5 | 6 | ## Prerequisites 7 | 8 | Make sure you have completed the prerequisites from [Exercise 0 - Get an ABAP Environment Trial](../ex0/README.md). 9 | 10 | Even if you already have an ABAP Environment Trial, **please get a new instance** as the trial systems have been updated for the TechEd 2023 sessions! 11 | 12 | ## Exercise 1.1 - Read: Scope of the Tutorial 13 | 14 | TL;DR [Skip the reading and start the hands-on](#exercise-13---hands-on-use-the-flight-data-model-for-analytics) 15 | 16 | What you will do in the course of this Hands-On session is focussed on the lower level of this diagram: 17 | 18 | ![](/exercises/ex1/images/02-HandsOnScope.png) 19 | 20 | **ABAP CDS:** In this hands-on, you will mainly build an analytical data model on top of the transactional model that consists of a multi-dimensional cube view, according analytical dimension views as well as an analytical query that reads from the cube. You will enhance the model step by step wit additional features. This will introduce you to 21 | - basic analytical ideas and terms (measures & dimensions, cubes & queries) 22 | - analytical data modelling principles (the star schema) 23 | - the meaning of “multi-dimensional” analytics 24 | 25 | **INA SERVICE:** In contrary to the transactional-focussed OData protocol, the InA protocol is tailored to the needs of analytical applications, communicating with the analytical engine. The service exposure as such works in the same way as for transactional services and can theoretically also be done in the trial systems, but as we do not (yet) have multi-dimensional end-user clients 26 | available as part of the trial experience, the service exposure part is not needed in the hands-on.
27 | You may want to check the Tutorial [Develop and Consume Queries on SAP Analytics Cloud](https://developers.sap.com/tutorials/abap-environment-analytics.html) (starts with step 10) or the Devtoberfest 2023 Session [Introduction to Embedded Analytics in ABAP Cloud](https://www.youtube.com/watch?v=2dIqQNnYKjY&list=PLBoQ2iTAoalS9Urg3jcyVjGtxb15Gudfq) (starts at 28:30) on how to expose the query. 28 | 29 | 30 | **CLIENTS:** As there are no multi-dimensional analytical end user clients available in trial, we enabled the multi-dimensional Fiori preview on the query in the trial system. We will use this preview to visualise the model. It works in the same way as an analytical end user application. In the hands-on, you will start the preview and will be introduced to its features. This will deepen the understanding you gained during the modeling exercise.
31 | To see, how the SAC client would look like, you can also check the [Tutorial](https://developers.sap.com/tutorials/abap-environment-analytics.html) (starts with step 16) or the [Devtoberfest Session](https://www.youtube.com/watch?v=2dIqQNnYKjY&list=PLBoQ2iTAoalS9Urg3jcyVjGtxb15Gudfq) (around minute 38). 32 | 33 | 34 | ## Exercise 1.2 - Read: Embedded Analytics in ABAP Cloud 35 | 36 | TL;DR [Skip the reading and start the hands-on](#exercise-13---hands-on-use-the-flight-data-model-for-analytics) 37 | 38 | Let's understand how Analytics is ***embedded*** in ABAP Cloud. 39 |
![](/exercises/ex1/images/01-EmbeddedAnalyticsInABAPCloud.png) 40 | 1. SAP HANAs column store is vital for analytical data processing 41 | 2. Analytical data modelling is done ABAP Cloud style via ABAP CDS entities 42 | 3. Service Exposure via the multi-dimensional InA protocol is included in ABAP Cloud and so is the analytical engine, the according multi-dimensional runtime 43 | 5. The developer tooling needed for Analytics is included in the ABAP development tools 44 | 6. Analytical Fiori UIs that are part of ABAP Cloud are in preparation 45 | 7. SAP Analytics Cloud "SAC" can be used as client with multi-dimensional capabilities 46 | 47 | So everything that is needed to build real analytical applications end-to-end is ***embedded*** in the ABAP Cloud programming model as well as in every ABAP Cloud based system 48 | 49 | 50 | ## Exercise 1.3 - Hands-On: Use the FLIGHT Data Model for Analytics 51 | 52 | In the hands-on, we will use the SAP Flight Model. The mission will be to analyse the occupation rate of flights. 53 | After completing these steps you will have an understanding about how you can use the FLIGHT model as the basis for an analytical data model. 54 | 55 | **Step 1)** Open ABAP Development Tools and open your trial project. 56 | 57 | **Step 2)** Use the "Open Development Object" button to open the /DMO/I_Flight CDS View.
Hint: How it looks like in ADT

![ABAP Development Tools](/exercises/ex1/images/03-ADTDemoFlight.png)

58 | 59 | **Step 3)** Analytics is about measuring, so we first need to decide what to measure. This figure is called a ***measure*** in analytical terms. It has to be numerical. Typical measures are amounts or quantities, but can also be counts of something. Have a look at the "/DMO/I_Flight" CDS View, find suitable measures & note them down. 60 |
Solution

61 | 62 | ```abap 63 | @AccessControl.authorizationCheck: #NOT_REQUIRED 64 | @EndUserText.label: 'Flight View - CDS Data Model' 65 | //... 66 | 67 | define view entity /DMO/I_Flight 68 | as select from /dmo/flight as Flight 69 | 70 | //... 71 | { 72 | //... 73 | 74 | /* A price is a typical measure */ 75 | @Semantics.amount.currencyCode: 'CurrencyCode' 76 | Flight.price as Price, 77 | 78 | //... 79 | 80 | /* Maximum Seats and Occupied Seats are numerical and will help calculating the occupation rate */ 81 | Flight.seats_max as MaximumSeats, 82 | Flight.seats_occupied as OccupiedSeats, 83 | 84 | //... 85 | } 86 | ``` 87 |

88 | 89 | **Step 4)** We need to put measures into a perspective. This perspective is called ***dimension*** in analytical terms. Have a look at the "/DMO/I_Flight" CDS View, find suitable dimensions & note them down. 90 |
Solution

91 | 92 | ```abap 93 | @AccessControl.authorizationCheck: #NOT_REQUIRED 94 | @EndUserText.label: 'Flight View - CDS Data Model' 95 | //... 96 | 97 | define view entity /DMO/I_Flight 98 | as select from /dmo/flight as Flight 99 | 100 | //... 101 | { 102 | //... 103 | 104 | /* Key Fields are always dimensions */ 105 | key Flight.carrier_id as AirlineID, 106 | 107 | //... 108 | key Flight.connection_id as ConnectionID, 109 | 110 | //... 111 | key Flight.flight_date as FlightDate, 112 | 113 | //... 114 | 115 | /* Basically all fields that are no measures can be dimensions */ 116 | Flight.plane_type_id as PlaneType, 117 | 118 | //... 119 | } 120 | ``` 121 |

122 | 123 | ## Summary 124 | 125 | Now that you have analysed the FLIGHT data model, we know which elements are needed to start building our first analytical entity: The cube. 126 | Continue to - [Exercise 2 - Build a Cube](../ex2/README.md) 127 | -------------------------------------------------------------------------------- /exercises/ex1/images/01-EmbeddedAnalyticsInABAPCloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/teched2023-DT187v/e35519c03f0aaa8f8330e215079b1645d8145a5d/exercises/ex1/images/01-EmbeddedAnalyticsInABAPCloud.png -------------------------------------------------------------------------------- /exercises/ex1/images/02-HandsOnScope.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/teched2023-DT187v/e35519c03f0aaa8f8330e215079b1645d8145a5d/exercises/ex1/images/02-HandsOnScope.png -------------------------------------------------------------------------------- /exercises/ex1/images/03-ADTDemoFlight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/teched2023-DT187v/e35519c03f0aaa8f8330e215079b1645d8145a5d/exercises/ex1/images/03-ADTDemoFlight.png -------------------------------------------------------------------------------- /exercises/ex2/README.md: -------------------------------------------------------------------------------- 1 | # Exercise 2 - Build a Cube with Dimensions 2 | 3 | In this exercise, we will create a cube. The cube is the heart of our analytical model. It draws together all required measures & dimensions and defines the functionality of the analytical model. 4 | 5 | The cube view is a `view entity` with the header annotation `@Analytics.dataCategory: #CUBE`. 6 | A dimension view is a `view entity` with the header annotation `@Analytics.dataCategory: #DIMENSION`. 7 | 8 | ## Exercise 2.1 - Build the Basic Cube 9 | 10 | **Step 1)** Create your own sub-package like "ZDT187v_[YourInitials]" underneath ZLOCAL 11 | - add it to your favorite packages 12 | - as transport request create "ZDT187v [YourInitials] Flight Hands-On" 13 | 14 | **Step 2)** Create a Cube View in your package. 15 | - Right-click the package and choose
16 | - New -> Other Repository Object -> Core Data Services -> Data Definition
17 | - Click "Next"
18 | - Enter the name "ZDT187v_[YourInitials]_Flight_Cube"
19 | - Give it the description "Flight Cube"
20 | - As Referenced Object, use "/DMO/I_FLIGHT"
21 | - Click "Next"
22 | - Use your request from Step 1 23 | - Click "Next"
24 | - Use the template "Define a View Entity for a Cube" (Prerequisite is that you downloaded and installed the templates) 25 | - Click "Finish" 26 | 27 | **Step 3)** As the annotation inheritance is switched off, you need to manually add the annotation `@Semantics.amount.currencyCode` with the reference to the according currency code field to the price field. 28 | 29 | **Step 4)** Press SHIFT+F1 to nicely format your sorce code, then activate the view.
30 | Activating your cube view will raise a warning that your cube does not have an access protection.
31 | Usually you would define an access protection, a so called 'DCL' for the cube. We do not cover this in this hands-on session and will ignore this warning. 32 | 33 |
Hint: Your code should now look like this

34 | 35 | ```abap 36 | 37 | /* setting the value to #NOT_REQUIRED would remove the warning */ 38 | @AccessControl.authorizationCheck: #CHECK 39 | @EndUserText.label: 'Flight Cube' 40 | /* Stopping annotation inheritance can help avoiding confusions */ 41 | @Metadata.ignorePropagatedAnnotations: true 42 | 43 | /* This header annotation makes the view entity an analytical cube */ 44 | @Analytics.dataCategory: #CUBE 45 | @Analytics.internalName: #LOCAL 46 | 47 | define view entity ZDT187v_[YourInitials]_Flight_Cube as select from /DMO/I_Flight { 48 | key AirlineID, 49 | key ConnectionID, 50 | key FlightDate, 51 | 52 | @Semantics.amount.currencyCode: 'CurrencyCode' 53 | Price, 54 | 55 | CurrencyCode, 56 | PlaneType, 57 | MaximumSeats, 58 | OccupiedSeats, 59 | 60 | /* Associations */ 61 | _Airline, 62 | _Connection 63 | _Currency 64 | } 65 | 66 | ``` 67 |

68 | 69 | **Step 5)** Now that you created your first analytical object in the ABAP Development Tools, right-click it in the project explorer, then choose 'Show in' -> 'Relation Explorer'. This perspective is an alternative view to the project explorer that is dedicated to analytical data models.
70 |
The Relation Explorer

71 | 72 | ![Relation Explorer](./images/01-RelationExplorer.png) 73 | 74 |

75 | 76 | ## Exercise 2.2 - Prepare the Measures 77 | 78 | Measures in an analytical cube need to be prepared so that an aggregation can take place when querying. The analytical engine needs an aggregation type as well as the right units and currency codes for quantities and amounts. 79 | 80 | **Step 1)** Identify your measures, put them in a suitable order together between the dimensions and the associations. 81 | 82 | **Step 2)** Add the annotation `@Aggregation.default` with a suitabble value (either `#SUM`, `#MIN` or `#MAX`) to your measures. 83 | 84 | **Step 3)** Add an additional measure that will act as a counter for the flights. 85 | - The expression to be used for this is `cast (1 as abap.int4) as TotalFlights` 86 | - The cast makes sure that the resulting data type is able to count to 2.147.483.647 (without the cast it would have been 256 - a 2 byte integer) 87 | - Give it a suitable aggregation as well 88 | 89 |
Hint: Your code should now look like this

90 | 91 | ```abap 92 | 93 | @EndUserText.label: 'Flight Cube' 94 | @Metadata.ignorePropagatedAnnotations: true 95 | @AccessControl.authorizationCheck: #NOT_REQUIRED 96 | @Analytics.dataCategory: #CUBE 97 | 98 | define view entity ZDT187v_[YourInitials]_Flight_Cube 99 | as select from /DMO/I_Flight 100 | 101 | { 102 | key AirlineID, 103 | 104 | key ConnectionID, 105 | 106 | key FlightDate, 107 | 108 | PlaneType, 109 | 110 | /* Measures */ 111 | 112 | CurrencyCode, 113 | @Semantics.amount.currencyCode: 'CurrencyCode' 114 | @Aggregation.default: #MAX 115 | Price, 116 | 117 | @Aggregation.default: #SUM 118 | MaximumSeats, 119 | 120 | @Aggregation.default: #SUM 121 | OccupiedSeats, 122 | 123 | @Aggregation.default: #SUM 124 | cast (1 as abap.int4) as TotalFlights, 125 | 126 | /* Associations */ 127 | 128 | _Airline, 129 | _Connection 130 | } 131 | 132 | ``` 133 |

134 | 135 | ## Exercise 2.3 - Prepare the Dimensions 136 | 137 | The current dimension fields in the cube view are just IDs. In order to be displayed nicely with an according text and with the option to display additional attributes (e.g. the name and city of the airline or the distance or the departure airport of the connection), we need to reference the according dimension views as foreign key references to them. This can not only be done for the key fields of the cube view, but for all dimension fields. 138 | 139 | For the airline and the connection, we do already have associations that we took over from /DMO/I_Flight, but these lead to master data views that are not built for the usage as analytical dimensions. Therefore, we will have to replace them. We will also remove the association to the currency view as we don't want to use it. 140 | 141 | You will now create the needed dimension views. 142 | 143 | | Association Alias | Target | Dimension View | 144 | | --- | --- | --- | 145 | | _Airline | /dmo/carrier (table) | ZDT187v_[YourInitials]_Airline_Dim | 146 | | _Connection | /dmo/connection (table) | ZDT187v_[YourInitials]_Connection_Dim | 147 | 148 | **Step 1)** Create the dimension view for the Airline. 149 | - Proceed as described in 2.1, step 2 but use the template "Define a View Entity for a Dimension" instead 150 | - Naming and targets, see table above 151 | 152 | **Step 2)** Enter the representative key as value of the `@ObjectModel.representativeKey` annotation.
153 | The representative key is the most specific key of your key fields. In our case there is only one key field: CarrierId. 154 | 155 | **Step 3)** Enter the Name field as value of the `@ObjectModel.text.element` annotation.
156 | This will improve the usability of your analytical application as the airline name can now be displayed along with the airline id. 157 | 158 | **Step 4)** Press SHIFT+F1 to nicely format your sorce code. Then activate the view. 159 | 160 |
Hint: Your ZDT187v_[YourInitials]_Airline_Dim code should now look like this

161 | 162 | ```abap 163 | 164 | @AccessControl.authorizationCheck: #CHECK 165 | @EndUserText.label: 'Carrier Dimension' 166 | @Metadata.ignorePropagatedAnnotations: true 167 | @Analytics.dataCategory: #DIMENSION 168 | @Analytics.internalName: #LOCAL 169 | @ObjectModel.representativeKey: 'CarrierId' 170 | 171 | define view entity ZDT187v_[YourInitials]_Airline_Dim 172 | as select from /dmo/carrier 173 | { 174 | @ObjectModel.text.element: ['Name'] 175 | key carrier_id as CarrierId, 176 | @Semantics.text: true 177 | name as Name, 178 | currency_code as CurrencyCode, 179 | local_created_by as LocalCreatedBy, 180 | local_created_at as LocalCreatedAt, 181 | local_last_changed_by as LocalLastChangedBy, 182 | local_last_changed_at as LocalLastChangedAt, 183 | last_changed_at as LastChangedAt 184 | } 185 | 186 | ``` 187 |

188 | 189 | **Step 5)** Now create the dimension view for the connection in the same way. 190 | - Set the representative Key to 'ConnectionId'. 191 | 192 | **Step 6)** Optional: Check the hint to see how a readable text 'Trip' was created and used as text element for the ConnectionId. 193 | 194 |
Hint: Calculated text element

195 | 196 | ```abap 197 | 198 | //... 199 | 200 | @ObjectModel.text.element: ['Trip'] 201 | key connection_id as ConnectionId, 202 | 203 | //... 204 | concat(airport_from_id, concat('->', airport_to_id)) as Trip, 205 | 206 | //... 207 | 208 | ``` 209 |

210 | 211 | **Step 7)** Add an association to the Airline dimension that you created before and use it as foreign key association on the AirlineId. 212 | - `association [1] to ZDT187v_[YourInitials]_Airline_Dim as _Airline on $projection.CarrierId = _Airline.CarrierId` 213 | - `@ObjectModel.foreignKey.association: '_Airline'` 214 | 215 | **Step 8)** Press SHIFT+F1 to nicely format your sorce code. Then activate the view. 216 | 217 |
Hint: Your ZDT187v_[YourInitials]_Connection_Dim code should now look like this

218 | 219 | ```abap 220 | 221 | @AccessControl.authorizationCheck: #NOT_REQUIRED 222 | @EndUserText.label: 'Connection Dimension' 223 | @Metadata.ignorePropagatedAnnotations: true 224 | @Analytics.dataCategory: #DIMENSION 225 | @Analytics.internalName: #LOCAL 226 | @ObjectModel.representativeKey: 'ConnectionId' 227 | 228 | define view entity ZDT187v_[YourInitials]_Connection_Dim 229 | as select from /dmo/connection 230 | association [1] to ZDT187v_[YourInitials]_Airline_Dim as _Airline on $projection.CarrierId = _Airline.CarrierId 231 | { 232 | @ObjectModel.foreignKey.association: '_Airline' 233 | key carrier_id as CarrierId, 234 | @ObjectModel.text.element: ['Trip'] 235 | key connection_id as ConnectionId, 236 | airport_from_id as AirportFromId, 237 | airport_to_id as AirportToId, 238 | concat(airport_from_id, concat('->', airport_to_id)) as Trip, 239 | departure_time as DepartureTime, 240 | arrival_time as ArrivalTime, 241 | distance as Distance, 242 | distance_unit as DistanceUnit, 243 | _Airline 244 | } 245 | 246 | ``` 247 |

248 | 249 | ## Exercise 2.4 - Use the Dimensions 250 | 251 | Back in your cube view, create associations to the dimension views, expose the associations so that they can finally be used as foreign key reference on your dimension fields. 252 | 253 | | Association Alias | Dimension View | 254 | | --- | --- | 255 | | _Airline | ZDT187v_[YourInitials]_Airline_Dim | 256 | | _Connection | ZDT187v_[YourInitials]_Connection_Dim | 257 | | _FlightDate | I_CalendarDate | 258 | 259 | **Step 1)** Add an association to the airline dimension you created in Exercise 2.2, Step 1 and expose it as _Airline. 260 | 261 |
Hint: An association is defined right after the `select from` clause. For the airline dimension, it will look like this

262 | 263 | `association [0..1] to ZDT187v_[YourInitials]_Airline_Dim as _Airline on _Airline.CarrierId = $projection.AirlineID`
264 | 265 |

266 | 267 | **Step 2)** Add an association to the connection dimension that you created in Exercise 2.2, Step 2 in the same way. Expose it as _Connection. 268 |
Hint: The association to the connection dimension will look like this

269 | 270 | `association [0..1] to ZDT187v_[YourInitials]_Connection_Dim as _Connection on _Connection.CarrierId = $projection.AirlineID and _Connection.ConnectionId = $projection.ConnectionID` 271 | 272 |

273 | 274 | **Step 3)** Add an association to the dimension I_CalendarDate in the same way. Expose it by adding its alias _FlightDate to the element list. 275 | 276 |
Hint: The association to I_CalendarDate will look like this

277 | 278 | `association [0..1] to I_CalendarDate as _FlightDate on _FlightDate.CalendarDate = $projection.FlightDate` 279 | 280 |

281 | 282 | **Step 4)** Add the associations you just introduced as foreign key relations to your dimension key fields by using the annotation `@ObjectModel.foreignKey.association`. As value, choose the alias of the exposed association. 283 | 284 | **Step 5)** Press SHIFT+F1 to nicely format your sorce code. Then activate the view. 285 | 286 |
Hint: Your cube code should now look like this

287 | 288 | ```abap 289 | 290 | @EndUserText.label: 'Flight Cube' 291 | @Metadata.ignorePropagatedAnnotations: true 292 | @AccessControl.authorizationCheck: #NOT_REQUIRED 293 | @Analytics.dataCategory: #CUBE 294 | 295 | define view entity ZDT187v_[YourInitials]_Flight_Cube 296 | as select from /DMO/I_Flight 297 | association [0..1] to ZDT187v_[YourInitials]_Airline_Dim as _Airline on _Airline.CarrierId = $projection.AirlineID 298 | association [0..1] to ZDT187v_[YourInitials]_Connection_Dim as _Connection on _Connection.CarrierId = $projection.AirlineID 299 | and _Connection.ConnectionId = $projection.ConnectionID 300 | association [0..1] to I_CalendarDate as _FlightDate on _FlightDate.CalendarDate = $projection.FlightDate 301 | 302 | { 303 | @ObjectModel.foreignKey.association: '_Airline' 304 | key AirlineID, 305 | 306 | @ObjectModel.foreignKey.association: '_Connection' 307 | key ConnectionID, 308 | 309 | @ObjectModel.foreignKey.association: '_FlightDate' 310 | key FlightDate, 311 | 312 | PlaneType, 313 | 314 | /* Measures */ 315 | 316 | CurrencyCode, 317 | 318 | @Semantics.amount.currencyCode: 'CurrencyCode' 319 | @Aggregation.default: #MAX 320 | Price, 321 | 322 | @Aggregation.default: #SUM 323 | MaximumSeats, 324 | 325 | @Aggregation.default: #SUM 326 | OccupiedSeats, 327 | 328 | @Aggregation.default: #SUM 329 | cast (1 as abap.int4) as TotalFlights, 330 | 331 | /* Associations for Dimensions */ 332 | 333 | _Airline, 334 | _Connection, 335 | _FlightDate 336 | } 337 | 338 | ``` 339 |

340 | 341 | ## Exercise 2.5 - Optional: Add and use additional Dimensions 342 | 343 | The cube that we have prepared now is ready to be used, but we want to add some additional functionality to it in terms of dimensions that we later can aggregate by. 344 | Even though we have added dimension views that give us access to additional display attributes like the departure or arrival airport of the destination or the month and quarter of the flight date, we would not be able to use these attributes as criteria to aggregate by. Every field that we want to use as aggregation criteria later on has to be an element of the cube view. 345 | Therefore, we will now use the associations to the dimensions to add those fields directly to the cube. 346 | 347 | If you are in a hurry, continue to - [Exercise 3 - Build a Cube ](../ex3/README.md) as the optional exercise will take some time. 348 | 349 | 350 | **Step 1)** Optional: Use the _Connection association to add target and destiantion airport as dimensions 351 | 352 |
Hint

353 | 354 | ```abap 355 | 356 | define view entity ZDT187v_[YourInitials]_Flights_Cube 357 | //... 358 | { 359 | //... 360 | _Connection.AirportFromId, 361 | _Connection.AirportToId, 362 | /... 363 | } 364 | 365 | ``` 366 |

367 | 368 | **Step 2)** Optional: Create an additional dimension view ZDT187v_[YourInitials]_Airport_Dim. 369 | - Proceed as described in Exercise 2.1, Step 2 370 | - choose /dmo/airport as the referenced data source 371 | - use the template "Define a View Entity for a Dimension" 372 | - fill in the representative key and text element 373 | - Press SHIFT+F1 to nicely format your sorce code. Then activate the view 374 | 375 |
Hint: Your ZDT187v_[YourInitials]_Airport_Dim code should now look like this

376 | 377 | ```abap 378 | 379 | @AccessControl.authorizationCheck: #CHECK 380 | @EndUserText.label: 'Airport Dimension' 381 | @Metadata.ignorePropagatedAnnotations: true 382 | @Analytics.internalName: #LOCAL 383 | @Analytics.dataCategory: #DIMENSION 384 | @ObjectModel.representativeKey: 'AirportId' 385 | 386 | define view entity ZDT187v_[YourInitials]_Airport_Dim 387 | as select from /dmo/airport 388 | { 389 | @ObjectModel.text.element: ['Name'] 390 | key airport_id as AirportId, 391 | name as Name, 392 | city as City, 393 | country as Country 394 | } 395 | 396 | ``` 397 |

398 | 399 | **Step 3)** Optional: Use the new dimension view in your cube. 400 | - Add two associations to the new dimension in your cube view 401 | - one for the origin airport `as _AirportFrom` 402 | - another one for the destination airport `as _AirportTo` 403 | - expose both 404 | - and use them as foreign key reference for the AirportFrom and the AirportTo field 405 | 406 |
Hint

407 | 408 | ```abap 409 | 410 | define view entity ZDT187v_[YourInitials]_Flights_Cube 411 | //... 412 | association [0..1] to ZDT187v_[YourInitials]_Airport_Dim as _AirportFrom on _AirportFrom.AirportId = $projection.AirportFromId 413 | association [0..1] to ZDT187v_[YourInitials]_Airport_Dim as _AirportTo on _AirportTo.AirportId = $projection.AirportToId 414 | { 415 | //... 416 | @ObjectModel.foreignKey.association: '_AirportFrom' 417 | _Connection.AirportFromId, 418 | 419 | @ObjectModel.foreignKey.association: '_AirportTo' 420 | _Connection.AirportToId, 421 | 422 | /... 423 | _AirportFrom, 424 | _AirportTo, 425 | /... 426 | } 427 | 428 | ``` 429 |

430 | 431 | 432 | **Step 4)** Optional: Sometimes, dimensions can also include measures. To be able to analyse and aggregate them, they need to be part of the cube as well.
433 | Use the _Connection association to add the flight distance together with the distance unit as additional measure. 434 | - As the distance is an amount with a unit, you need to add `@Semantics.quantity.unitOfMeasure: 'DistanceUnit'` to it 435 | - as well as a suitable aggregation, e.g. `@Aggregation.default: #MAX` 436 | 437 |
Hint

438 | 439 | ```abap 440 | 441 | define view entity ZDT187v_[YourInitials]_Flights_Cube 442 | //... 443 | { 444 | //... 445 | _Connection.DistanceUnit, 446 | 447 | @Semantics.quantity.unitOfMeasure: 'DistanceUnit' 448 | @Aggregation.default: #MAX 449 | _Connection.Distance, 450 | 451 | /... 452 | } 453 | 454 | ``` 455 |

456 | 457 | 458 | **Step 5)** Optional: Use the _FlightDate association to add the flight quarter as well as the flight year as dimensions. 459 | - Add a label e.g. `@EndUserText.label: 'Flight Year'` to the field to give it a readable name 460 | - Explain the analytical engine that the field is a calendar year by setting `@Semantics.calendar.year: true`
461 | This will enable additional display attributes in the UI later on. 462 | - Finally set the fields in relation to the Flight Date with `@ObjectModel.value.derivedFrom: [ 'FlightDate' ]`
463 | This is again a hint for the analytical engine and is especially important if multiple dates are in your model. 464 | 465 |
Hint

466 | 467 | ```abap 468 | 469 | define view entity ZDT187v_[YourInitials]_Flights_Cube 470 | //... 471 | { 472 | //... 473 | @EndUserText.label: 'Flight Quarter' 474 | @Semantics.calendar.yearQuarter: true 475 | @ObjectModel.value.derivedFrom: [ 'FlightDate' ] 476 | _FlightDate.YearQuarter, 477 | 478 | @EndUserText.label: 'Flight Year' 479 | @Semantics.calendar.year: true 480 | @ObjectModel.value.derivedFrom: [ 'FlightDate' ] 481 | _FlightDate.CalendarYear, 482 | /... 483 | } 484 | 485 | ``` 486 |

487 | 488 | **Step 6)** Press SHIFT+F1 to nicely format your sorce code. Then activate the view. 489 | 490 | ## Summary 491 | 492 | You have now learned what measures and dimensions are and how to build an analytical cube view. The cube is the center of the analytical data model and the so called star schema. 493 | The cube defines the capabilities of your analytical model and draws together all measures and dimensions. Every dimension that you later want to aggregate by needs to be part of the cube view. 494 | Calculations that have to happen before the aggregation (like the counter that you introduced) have to happen in the cube as well. 495 | 496 |
Hint: Your final cube view should now look like this

497 | 498 | ```abap 499 | 500 | @AccessControl.authorizationCheck: #CHECK 501 | @EndUserText.label: 'Flight Cube' 502 | @Metadata.ignorePropagatedAnnotations: true 503 | @Analytics.dataCategory: #CUBE 504 | @Analytics.internalName: #LOCAL 505 | 506 | define view entity ZDT187v_[YourInitials]_Flights_Cube 507 | as select from /DMO/I_Flight 508 | association [0..1] to ZDT187v_[YourInitials]_Airline_Dim as _Airline on _Airline.CarrierId = $projection.AirlineID 509 | association [0..1] to ZDT187v_[YourInitials]_Connection_Dim as _Connection on _Connection.CarrierId = $projection.AirlineID 510 | and _Connection.ConnectionId = $projection.ConnectionID 511 | association [0..1] to I_CalendarDate as _FlightDate on _FlightDate.CalendarDate = $projection.FlightDate 512 | /* start optional associations */ 513 | association [0..1] to ZDT187v_[YourInitials]_Airport_Dim as _AirportFrom on _AirportFrom.AirportId = $projection.AirportFromId 514 | association [0..1] to ZDT187v_[YourInitials]_Airport_Dimn as _AirportTo on _AirportTo.AirportId = $projection.AirportToId 515 | /* end optional associations */ 516 | { 517 | @ObjectModel.foreignKey.association: '_Airline' 518 | key AirlineID, 519 | 520 | @ObjectModel.foreignKey.association: '_Connection' 521 | key ConnectionID, 522 | 523 | @ObjectModel.foreignKey.association: '_FlightDate' 524 | key FlightDate, 525 | 526 | PlaneType, 527 | 528 | /* start optional dimensions */ 529 | @ObjectModel.foreignKey.association: '_AirportFrom' 530 | _Connection.AirportFromId, 531 | 532 | @ObjectModel.foreignKey.association: '_AirportTo' 533 | _Connection.AirportToId, 534 | 535 | @EndUserText.label: 'Flight Quarter' 536 | @Semantics.calendar.yearQuarter: true 537 | @ObjectModel.value.derivedFrom: [ 'FlightDate' ] 538 | _FlightDate.YearQuarter, 539 | 540 | @EndUserText.label: 'Flight Year' 541 | @Semantics.calendar.year: true 542 | @ObjectModel.value.derivedFrom: [ 'FlightDate' ] 543 | _FlightDate.CalendarYear, 544 | /* end optional dimensions */ 545 | 546 | /* Measures */ 547 | 548 | CurrencyCode, 549 | 550 | @Semantics.amount.currencyCode: 'CurrencyCode' 551 | @Aggregation.default: #MAX 552 | Price, 553 | 554 | @Aggregation.default: #SUM 555 | MaximumSeats, 556 | 557 | @Aggregation.default: #SUM 558 | OccupiedSeats, 559 | 560 | @Aggregation.default: #SUM 561 | cast (1 as abap.int4) as TotalFlights, 562 | 563 | _Connection.DistanceUnit, 564 | 565 | /* start optional measure */ 566 | @Semantics.quantity.unitOfMeasure: 'DistanceUnit' 567 | @Aggregation.default: #MAX 568 | _Connection.Distance, 569 | /* end optional measure */ 570 | 571 | 572 | /* Associations for Dimensions */ 573 | 574 | _Airline, 575 | _Connection, 576 | 577 | /* start optional associations */ 578 | _AirportFrom, 579 | _AirportTo, 580 | _FlightDate 581 | /* end optional associations */ 582 | } 583 | 584 | ``` 585 |

586 | 587 | Continue to - [Exercise 3 - Build a Query ](../ex3/README.MD) 588 | -------------------------------------------------------------------------------- /exercises/ex2/images/01-RelationExplorer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/teched2023-DT187v/e35519c03f0aaa8f8330e215079b1645d8145a5d/exercises/ex2/images/01-RelationExplorer.png -------------------------------------------------------------------------------- /exercises/ex2/sources/ZDT187v_XX_Airline_Dim: -------------------------------------------------------------------------------- 1 | @AccessControl.authorizationCheck: #CHECK 2 | @EndUserText.label: 'Carrier Dimension' 3 | @Metadata.ignorePropagatedAnnotations: true 4 | @Analytics.dataCategory: #DIMENSION 5 | @Analytics.internalName: #LOCAL 6 | @ObjectModel.representativeKey: 'CarrierId' 7 | 8 | define view entity ZDT187v_[YourInitials]_Airline_Dim 9 | as select from /dmo/carrier 10 | { 11 | @ObjectModel.text.element: ['Name'] 12 | key carrier_id as CarrierId, 13 | @Semantics.text: true 14 | name as Name, 15 | currency_code as CurrencyCode, 16 | local_created_by as LocalCreatedBy, 17 | local_created_at as LocalCreatedAt, 18 | local_last_changed_by as LocalLastChangedBy, 19 | local_last_changed_at as LocalLastChangedAt, 20 | last_changed_at as LastChangedAt 21 | } 22 | -------------------------------------------------------------------------------- /exercises/ex2/sources/ZDT187v_XX_Airport_Dim: -------------------------------------------------------------------------------- 1 | @AccessControl.authorizationCheck: #CHECK 2 | @EndUserText.label: 'Airport Dimension' 3 | @Metadata.ignorePropagatedAnnotations: true 4 | @Analytics.internalName: #LOCAL 5 | @Analytics.dataCategory: #DIMENSION 6 | @ObjectModel.representativeKey: 'AirportId' 7 | 8 | define view entity ZDT187v_[YourInitials]_Airport_Dim 9 | as select from /dmo/airport 10 | { 11 | @ObjectModel.text.element: ['Name'] 12 | key airport_id as AirportId, 13 | name as Name, 14 | city as City, 15 | country as Country 16 | } 17 | -------------------------------------------------------------------------------- /exercises/ex2/sources/ZDT187v_XX_Connection_Dim: -------------------------------------------------------------------------------- 1 | @AccessControl.authorizationCheck: #CHECK 2 | @EndUserText.label: 'Connection Dimension' 3 | @Metadata.ignorePropagatedAnnotations: true 4 | @Analytics.dataCategory: #DIMENSION 5 | @Analytics.internalName: #LOCAL 6 | @ObjectModel.representativeKey: 'ConnectionId' 7 | 8 | define view entity ZDT187v_[YourInitials]_Connection_Dim 9 | as select from /dmo/connection 10 | association [1] to ZDT187v_[YourInitials]_Airline_Dim as _Airline on $projection.CarrierId = _Airline.CarrierId 11 | { 12 | @ObjectModel.foreignKey.association: '_Airline' 13 | key carrier_id as CarrierId, 14 | @ObjectModel.text.element: ['Trip'] 15 | key connection_id as ConnectionId, 16 | airport_from_id as AirportFromId, 17 | airport_to_id as AirportToId, 18 | concat(airport_from_id, concat('->', airport_to_id)) as Trip, 19 | departure_time as DepartureTime, 20 | arrival_time as ArrivalTime, 21 | distance as Distance, 22 | distance_unit as DistanceUnit, 23 | _Airline 24 | } 25 | -------------------------------------------------------------------------------- /exercises/ex2/sources/ZDT187v_XX_Flight_Cube: -------------------------------------------------------------------------------- 1 | @AccessControl.authorizationCheck: #CHECK 2 | @EndUserText.label: 'Flight Cube' 3 | @Metadata.ignorePropagatedAnnotations: true 4 | @Analytics.dataCategory: #CUBE 5 | @Analytics.internalName: #LOCAL 6 | 7 | define view entity ZDT187v_[YourInitials]_Flight_Cube 8 | as select from /DMO/I_Flight 9 | association [0..1] to ZDT187v_[YourInitials]_Airline_Dim as _Airline on _Airline.CarrierId = $projection.AirlineID 10 | association [0..1] to ZDT187v_[YourInitials]_Connection_Dim as _Connection on _Connection.CarrierId = $projection.AirlineID 11 | and _Connection.ConnectionId = $projection.ConnectionID 12 | association [0..1] to I_CalendarDate as _FlightDate on _FlightDate.CalendarDate = $projection.FlightDate 13 | /* start optional associations */ 14 | association [0..1] to ZDT187v_[YourInitials]_Airport_Dim as _AirportFrom on _AirportFrom.AirportId = $projection.AirportFromId 15 | association [0..1] to ZDT187v_[YourInitials]_Airport_Dim as _AirportTo on _AirportTo.AirportId = $projection.AirportToId 16 | /* end optional associations */ 17 | { 18 | @ObjectModel.foreignKey.association: '_Airline' 19 | key AirlineID, 20 | 21 | @ObjectModel.foreignKey.association: '_Connection' 22 | key ConnectionID, 23 | 24 | @ObjectModel.foreignKey.association: '_FlightDate' 25 | key FlightDate, 26 | 27 | PlaneType, 28 | 29 | /* start optional dimensions */ 30 | @ObjectModel.foreignKey.association: '_AirportFrom' 31 | _Connection.AirportFromId, 32 | 33 | @ObjectModel.foreignKey.association: '_AirportTo' 34 | _Connection.AirportToId, 35 | 36 | @EndUserText.label: 'Flight Quarter' 37 | @Semantics.calendar.yearQuarter: true 38 | @ObjectModel.value.derivedFrom: [ 'FlightDate' ] 39 | _FlightDate.YearQuarter, 40 | 41 | @EndUserText.label: 'Flight Year' 42 | @Semantics.calendar.year: true 43 | @ObjectModel.value.derivedFrom: [ 'FlightDate' ] 44 | _FlightDate.CalendarYear, 45 | /* end optional dimensions */ 46 | 47 | /* Measures */ 48 | 49 | CurrencyCode, 50 | 51 | @Semantics.amount.currencyCode: 'CurrencyCode' 52 | @Aggregation.default: #MAX 53 | Price, 54 | 55 | @Aggregation.default: #SUM 56 | MaximumSeats, 57 | 58 | @Aggregation.default: #SUM 59 | OccupiedSeats, 60 | 61 | @Aggregation.default: #SUM 62 | cast (1 as abap.int4) as TotalFlights, 63 | 64 | _Connection.DistanceUnit, 65 | 66 | /* start optional measure */ 67 | @Semantics.quantity.unitOfMeasure: 'DistanceUnit' 68 | @Aggregation.default: #MAX 69 | _Connection.Distance, 70 | /* end optional measure */ 71 | 72 | 73 | /* Associations for Dimensions */ 74 | 75 | _Airline, 76 | _Connection, 77 | 78 | /* start optional associations */ 79 | _AirportFrom, 80 | _AirportTo, 81 | _FlightDate 82 | /* end optional associations */ 83 | } 84 | -------------------------------------------------------------------------------- /exercises/ex3/README.MD: -------------------------------------------------------------------------------- 1 | # Exercise 3 - Build an analytical Query 2 | 3 | Now that we have built the analytical ***cube*** that defines the capabilities of our analytical model, lets formulate a ***query*** to that model.
4 | The query defines more or less the initial layout of the table (the table is kind of a pivot table) that will be displayed in your analytical application. 5 | 6 | The analytical query view is a `transient view entity` with the `provider contract analytical_query`. 7 | 8 | ## Exercise 3.1 - Build the initial Query 9 | 10 | **Step 1)** Create a Query View in your package. 11 | - Right-click the package and choose
12 | - New -> Other Repository Object -> Core Data Services -> Data Definition
13 | - Click "Next"
14 | - Enter the name "ZDT187v_[YourInitials]_Flight_Query"
15 | - Give it the description "Flight Query"
16 | - As Referenced Object, use "ZDT187v_[YourInitials]_Flight_Cube"
17 | - Click "Next"
18 | - Use your request "ZDT187v [YourInitials] Flight Hands-On"
19 | - Click "Next"
20 | - Use the template "Define a View Entity for a Query" (Prerequisite is that you downloaded and installed the templates) 21 | - Click "Finish" 22 | 23 | **Step 2)** Fix the errors by removing the 'key' keyword. A query does not need them. Unfortunately this cannot be noted in templates.
24 | 25 |
Hint: Your code should now look like this

26 | 27 | ```abap 28 | 29 | @AccessControl.authorizationCheck: #NOT_ALLOWED 30 | @EndUserText.label: 'Flight Query' 31 | 32 | define transient view entity ZDT187v_[YourInitials]_Flight_Query 33 | provider contract analytical_query 34 | as projection on ZDT187v_[YourInitials]_Flight_Cube { 35 | AirlineID, 36 | ConnectionID, 37 | FlightDate, 38 | PlaneType, 39 | AirportFromId, 40 | AirportToId, 41 | YearQuarter, 42 | CalendarYear, 43 | Price, 44 | CurrencyCode, 45 | MaximumSeats, 46 | OccupiedSeats, 47 | TotalFlights, 48 | DistanceUnit, 49 | Distance, 50 | /* Associations */ 51 | _Airline, 52 | _AirportFrom, 53 | _AirportTo, 54 | _Connection, 55 | _FlightDate 56 | } 57 | 58 | ``` 59 |

60 | 61 | **Step 3)** Define the layout by assigning the axis as well as the existence of totals for the dimension.
62 | For the axis, the annotation `@AnalyticsDetails.query.axis` is used.
63 | For the totals, we use `@AnalyticsDetails.query.totals`.
64 | In a standard layout, dimensions are on the row axis and the measures are on the column axis.
65 | If you assign a dimension to a different axis or remove it, the measures will be aggregated according to the layout.
66 | Example: If you have the price in the columns and only add the airline to the rows (either by removing other dimensions or by assigning them to the `#FREE` axis), then the maximum price of all flights that are conducted by the airline will be the result of the aggregation (assuming the default aggregation of the price is set to `#MAX`). 67 | 68 |
Hint: See how it looks like

69 | 70 | ```abap 71 | 72 | /* You can freely decide if you write the annotations either in a flat or on object style */ 73 | 74 | /* Object Style */ 75 | @AnalyticsDetails.query: { 76 | axis: #ROWS, 77 | totals: #HIDE 78 | } 79 | AirlineID 80 | 81 | /* Flat Style */ 82 | @AnalyticsDetails.query.axis: #ROWS 83 | @AnalyticsDetails.query.totals: #HIDE 84 | AirlineID 85 | 86 | ``` 87 |

88 | 89 | 90 | ## Exercise 3.2 - Prepare the Measures 91 | 92 | Generally, all measures will always be (in a group) on the same axis. If you do not assign an axis at all, they will be on the column axis by default. 93 | If you assign different axes to the measures, the first one will win. For readability reasons, we will add the axis annotations to all measures here. 94 | 95 | **Step 1)** Add the `@AnalyticsDetails.query.axis: #COLUMNS` annotation to all measures. 96 | 97 | **Step 2)** Add a new (calculated) measure to the query by calculating the occupation rate as a percentage using the MaximumSeats and OccupiedSeats fields.
98 | Remember: Measures that need to be calculated after the aggregation have to be part of the query. 99 | 100 |
Hint: See how it looks like

101 | 102 | ```abap 103 | 104 | /* label for a better user experience */ 105 | @EndUserText.label: 'Occupation Rate' 106 | /* as the aggrregation is set already for the fields that are used in the calculation, we leave it up to the engine to decide for our formula */ 107 | @Aggregation.default: #FORMULA 108 | /* the calculation formula */ 109 | $projection.occupiedseats / $projection.maximumseats * 100 as OccupationRate, 110 | 111 | ``` 112 |

113 | 114 | **Step 3)** Optional: To indicate, that the occupation rate is a percentage, add an according unit to it.
115 | This will need introducing the unit as a field & then referencing it from the calculated field. 116 | 117 |
Hint: See how it looks like

118 | 119 | ```abap 120 | 121 | /* introduce the unit */ 122 | cast( '%' as abap.unit ) as unitPercent, 123 | /... 124 | /* reference the new unit */ 125 | @Semantics.quantity.unitOfMeasure: 'unitPercent' 126 | $projection.occupiedseats / $projection.maximumseats * 100 as OccupationRate, 127 | 128 | ``` 129 |

130 | 131 | **Step 4)** Introduce a currency conversion for the price.
132 | As the price is listed in different currencies, it has to be converted so that it can be aggregated. 133 | 134 |
Hint: Currency Conversion

135 | 136 | ```abap 137 | 138 | @AnalyticsDetails.query.axis: #COLUMNS 139 | @Semantics.amount.currencyCode: 'CurrencyCode' 140 | @Aggregation.default: #FORMULA 141 | currency_conversion ( 142 | amount => curr_to_decfloat_amount( Price ), 143 | source_currency => CurrencyCode, 144 | target_currency => cast ( 'EUR' as abap.cuky( 5 ) ) , 145 | exchange_rate_date => cast ( '20230101' as abap.dats), 146 | exchange_rate_type => 'M' 147 | ) as Price, 148 | 149 | ``` 150 |

151 | 152 | **Step 5)** Introduce a virtual unit for the price.
153 | In case the price cannot be converted e.g. due to missing conversion rates, this has to be considered by displaying the original currency and amount instead of the target currency. 154 | 155 |
Hint: Virtual unit

156 | 157 | ```abap 158 | 159 | virtual GlobalCurrency : abap.cuky( 5 ), 160 | /... 161 | @Semantics.amount.currencyCode: 'GlobalCurrency' 162 | /... 163 | currency_conversion ( 164 | /... 165 | ) as Price, 166 | 167 | ``` 168 |

169 | 170 | **Step 6)** Format & activate your analytical query view. 171 | 172 |
Hint: Your query should now look like this

173 | 174 | ```abap 175 | 176 | @AccessControl.authorizationCheck: #NOT_ALLOWED 177 | @EndUserText.label: 'Flight Query' 178 | 179 | define transient view entity ZDT187v_[YourInitials]_Flight_Query 180 | provider contract analytical_query 181 | as projection on ZDT187v_[YourInitials]_Flight_Cube 182 | { 183 | /* Dimensions */ 184 | 185 | @AnalyticsDetails.query.axis: #ROWS 186 | @AnalyticsDetails.query.totals: #HIDE 187 | AirlineID, 188 | 189 | @AnalyticsDetails.query.axis: #ROWS 190 | @AnalyticsDetails.query.totals: #HIDE 191 | ConnectionID, 192 | 193 | @AnalyticsDetails.query.axis: #ROWS 194 | @AnalyticsDetails.query.totals: #HIDE 195 | FlightDate, 196 | 197 | @AnalyticsDetails.query.axis: #FREE 198 | @AnalyticsDetails.query.totals: #HIDE 199 | PlaneType, 200 | 201 | @AnalyticsDetails.query.axis: #ROWS 202 | @AnalyticsDetails.query.totals: #SHOW 203 | AirportFromId, 204 | 205 | @AnalyticsDetails.query.axis: #FREE 206 | @AnalyticsDetails.query.totals: #HIDE 207 | AirportToId, 208 | 209 | @AnalyticsDetails.query.axis: #FREE 210 | @AnalyticsDetails.query.totals: #HIDE 211 | YearQuarter, 212 | 213 | @AnalyticsDetails.query.axis: #FREE 214 | @AnalyticsDetails.query.totals: #SHOW 215 | CalendarYear, 216 | 217 | /* Measures */ 218 | 219 | @AnalyticsDetails.query.axis: #COLUMNS 220 | @Semantics.amount.currencyCode: 'GlobalCurrency' 221 | @Aggregation.default: #FORMULA 222 | currency_conversion ( 223 | amount => curr_to_decfloat_amount( Price ), 224 | source_currency => CurrencyCode, 225 | target_currency => cast ( 'EUR' as abap.cuky( 5 ) ) , 226 | exchange_rate_date => cast ( '20230101' as abap.dats), 227 | exchange_rate_type => 'M' 228 | ) as Price, 229 | virtual GlobalCurrency : abap.cuky( 5 ), 230 | CurrencyCode, 231 | 232 | @AnalyticsDetails.query.axis: #COLUMNS 233 | MaximumSeats, 234 | 235 | @AnalyticsDetails.query.axis: #COLUMNS 236 | OccupiedSeats, 237 | 238 | @AnalyticsDetails.query.axis: #COLUMNS 239 | @EndUserText.label: 'Occupation Rate' 240 | @Aggregation.default: #FORMULA 241 | @Semantics.quantity.unitOfMeasure: 'unitPercent' 242 | $projection.occupiedseats / $projection.maximumseats * 100 as OccupationRate, 243 | cast( '%' as abap.unit ) as unitPercent, 244 | 245 | @AnalyticsDetails.query.axis: #COLUMNS 246 | TotalFlights, 247 | 248 | @AnalyticsDetails.query.axis: #COLUMNS 249 | Distance, 250 | DistanceUnit, 251 | 252 | /* Associations */ 253 | _Airline, 254 | _AirportFrom, 255 | _AirportTo, 256 | _Connection, 257 | _FlightDate 258 | } 259 | 260 | ``` 261 |

262 | 263 | **Step 7)** Preview the query by right-clicking the query in the explorer and selecting 'Preview'.
264 | Be patient. It's just a free trial system ;-) 265 | 266 | ## Exercise 3.3 - Working with the Multi-Dimensional Analysis 267 | 268 | **Step 1)** Preview the query with the multi-dimensional analysis.
269 | To make use of the new multi-dimensional analysis based preview that we introduced to the trial systems, proceed as follows: 270 | - the preview for analytical queries opens in the browser 271 | - in case of an error, press F5 to reload 272 | - you may need to press 'go' to run the query 273 | - check if the result of the layout that you defined in the query meets your expectations 274 | 275 |
![](/exercises/ex3/images/01-MultiDimensionalPreview.png) 276 | 277 | **Step 2)** Try changing the layout in the app directly:
278 | - Open the layout side pannel (second icon from top in the right side bar) 279 | - Remove all attributes except the Airline from the rows 280 | - Remove all measures except for the occupation rate from the measures structure 281 | - Move the Departure Airport to the Columns 282 | - etc. 283 | 284 | **Step 3)** Try changing the display properties:
285 | - Right click the Departure Airport in the UI 286 | - Select Dimension -> Properties 287 | - Switch the Desciption on 288 | - Display Totals 289 | - Change the sorting 290 | - etc. 291 | 292 | **Step 4)** Add display attributes:
293 | - In the sidebar, expand the Flight Date and 294 | - select Calendar Quarter 295 | 296 | **Step 5)** Observe the currency conversion behaviour:
297 | - Notice the blue warning on the top left of the table 298 | - Click it and see that conversion rates are missing 299 | - Expand the measure structure and de-select all measures except for the price 300 | - Empty the rows an only take the Flight Date into the rows 301 | - See that some prices cannot be aggregated as they contain different currencies and no conversion is available
302 | These issues are indicated with an '*'. Some dates have flights only in one currency. They will be displayed. 303 | - Now exchange the Flight Date with the airline and see that the aggregation happens without conversion in the local currency. 304 | 305 | **Step 6)** Play ;-) 306 | 307 | **Step 7)** Also try modifying the layout in the query view and observe the results in the UI (re-publish, re-load) 308 | 309 | 310 | ## Summary 311 | 312 | You now got to know common analytical modelling practices and learned the most important analytical terms. 313 | You have an impression on what 'multi-dimensional' analytics means and how analytical UIs behave. 314 | 315 | ### What's next? 316 | 317 | You are ready to learn more about embedded analytics for example in: 318 | - The [SAP Help on ABAP Cloud Analytics](https://help.sap.com/docs/abap-cloud/abap-analytics/abap-analytics) 319 | - The [Embedded Analytics Overview - Blog Post](https://blogs.sap.com/2022/11/30/embedded-analytics-with-abap-cloud-a-brief-overview-part-1/) by [Fabian Fellhauer](https://people.sap.com/fabianfellhauer) 320 | 321 | Take a look at the [ABAP Platform Analytical Modeling Examples](https://github.com/SAP-samples/abap-platform-analytics-data-modeling) repository. It contains a complete analytical model based on the flight reference scenario as well as loads of additional analytical queries that showcase different features of Embedded Analytics in the ABAP Platform. 322 | 323 | Further links can be found in the [Jump-Start Session slides](/exercises/ex3/images/231018_Embedded-Analytics-for-TechEd_Ext.pdf). 324 | 325 | Feel free to use this tutorial as a basis and explore further modeling practices within the trial system. What about e.g. implementing a hierarchy? 326 | 327 | You may also want to check the transactional side of the story? Then head to the session [Use ABAP Cloud for developer extensibility](https://github.com/SAP-samples/teched2023-DT182v) from [Andrè Fischer](https://people.sap.com/andre.fischer). 328 | 329 | The [slides of the Jump-Start Session](/exercises/ex3/images/231018_Embedded-Analytics-for-TechEd_Ext.pdf) are available in this GitHub repository as well. 330 | 331 | -------------------------------------------------------------------------------- /exercises/ex3/images/01-MultiDimensionalPreview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/teched2023-DT187v/e35519c03f0aaa8f8330e215079b1645d8145a5d/exercises/ex3/images/01-MultiDimensionalPreview.png -------------------------------------------------------------------------------- /exercises/ex3/images/231018_Embedded-Analytics-for-TechEd_Ext.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/teched2023-DT187v/e35519c03f0aaa8f8330e215079b1645d8145a5d/exercises/ex3/images/231018_Embedded-Analytics-for-TechEd_Ext.pdf -------------------------------------------------------------------------------- /exercises/ex3/sources/ZDT187v_XX_Flight_Query: -------------------------------------------------------------------------------- 1 | @AccessControl.authorizationCheck: #NOT_ALLOWED 2 | @EndUserText.label: 'Flight Query' 3 | 4 | define transient view entity ZDT187v_[YourInitials]_Flight_Query 5 | provider contract analytical_query 6 | as projection on ZDT187v_[YourInitials]_Flight_Cube 7 | { 8 | /* Dimensions */ 9 | 10 | @AnalyticsDetails.query.axis: #ROWS 11 | @AnalyticsDetails.query.totals: #HIDE 12 | AirlineID, 13 | 14 | @AnalyticsDetails.query.axis: #ROWS 15 | @AnalyticsDetails.query.totals: #HIDE 16 | ConnectionID, 17 | 18 | @AnalyticsDetails.query.axis: #ROWS 19 | @AnalyticsDetails.query.totals: #HIDE 20 | FlightDate, 21 | 22 | @AnalyticsDetails.query.axis: #FREE 23 | @AnalyticsDetails.query.totals: #HIDE 24 | PlaneType, 25 | 26 | @AnalyticsDetails.query.axis: #ROWS 27 | @AnalyticsDetails.query.totals: #SHOW 28 | AirportFromId, 29 | 30 | @AnalyticsDetails.query.axis: #FREE 31 | @AnalyticsDetails.query.totals: #HIDE 32 | AirportToId, 33 | 34 | @AnalyticsDetails.query.axis: #FREE 35 | @AnalyticsDetails.query.totals: #HIDE 36 | YearQuarter, 37 | 38 | @AnalyticsDetails.query.axis: #FREE 39 | @AnalyticsDetails.query.totals: #SHOW 40 | CalendarYear, 41 | 42 | /* Measures */ 43 | 44 | @AnalyticsDetails.query.axis: #COLUMNS 45 | @Semantics.amount.currencyCode: 'GlobalCurrency' 46 | @Aggregation.default: #FORMULA 47 | currency_conversion ( 48 | amount => curr_to_decfloat_amount( Price ), 49 | source_currency => CurrencyCode, 50 | target_currency => cast ( 'EUR' as abap.cuky( 5 ) ) , 51 | exchange_rate_date => cast ( '20230101' as abap.dats), 52 | exchange_rate_type => 'M' 53 | ) as Price, 54 | virtual GlobalCurrency : abap.cuky( 5 ), 55 | CurrencyCode, 56 | 57 | @AnalyticsDetails.query.axis: #COLUMNS 58 | MaximumSeats, 59 | 60 | @AnalyticsDetails.query.axis: #COLUMNS 61 | OccupiedSeats, 62 | 63 | @AnalyticsDetails.query.axis: #COLUMNS 64 | @EndUserText.label: 'Occupation Rate' 65 | @Aggregation.default: #FORMULA 66 | @Semantics.quantity.unitOfMeasure: 'unitPercent' 67 | $projection.occupiedseats / $projection.maximumseats * 100 as OccupationRate, 68 | cast( '%' as abap.unit ) as unitPercent, 69 | 70 | @AnalyticsDetails.query.axis: #COLUMNS 71 | TotalFlights, 72 | 73 | @AnalyticsDetails.query.axis: #COLUMNS 74 | Distance, 75 | DistanceUnit, 76 | 77 | /* Associations */ 78 | _Airline, 79 | _AirportFrom, 80 | _AirportTo, 81 | _Connection, 82 | _FlightDate 83 | } 84 | --------------------------------------------------------------------------------