Share E-Book

Implementing SAP Business Suite on SAP HANA [prepare and execute a migration of SAP Business Suite from Any DB to SAP HANA … (Galileo Press Inc.Pytel, Michael)(Z-Library)

Author

,
,

Rating 3.5 AI initial rating

Log in to rate

SAP
Language English

No Description

Format PDF
Size 21.9 MB
(First 20 pages)

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Page 1
(This page has no text content)
Page 2
SAP PRESS is a joint initiative of SAP and Rheinwerk Publishing. The know-how offered by SAP specialists combined with the expertise of Rheinwerk Publishing offers the reader expert books in the field. SAP PRESS features first-hand information and expert advice, and provides useful skills for professional decision-making. SAP PRESS offers a variety of books on technical and business-related topics for the SAP user. For further information, please visit our website: www.sap-press.com. Michael Pytel Implementing SAP Business Suite on SAP HANA 2016, approx. 625 pp., hardcover ISBN 978-1-4932-1257-6 Merz, Hügens, Blum Implementing SAP BW on SAP HANA 2015, 467 pages, hardcover ISBN 978-1-4932-1003-9 Haun, Hickman, Loden, Wells Implementing SAP HANA (2nd edition) 2014, 860 pages, hardcover ISBN 978-1-4932-1176-0 Schneider, Westenberger, Gahm ABAP Development for SAP HANA 2013, 609 pages, hardcover ISBN 978-1-59229-859-4
Page 3
Anil Babu Ankisettipalli, Hansen Chen, Pranav Wankawala SAP HANA® Advanced Data Modeling Bonn Boston
Page 4
Dear Reader, Congratulations! By purchasing this book, you’ve taken the first step in advancing your career as an SAP HANA developer. As you know, beginner’s basics only go so far in tackling the real world obstacles of SAP HANA data model design. Business breeds complexity, and it’s your job to keep up. From modeling complex logic to building predictive models to calculating trends, the world of SAP HANA is bigger and more intricate than ever. However, fear not! Having worked closely with Anil Babu Ankisettipalli, Hansen Chen, and Pranav Wankawala, I can tell you, personally, that you are in good hands. There’s a difficulty and craft involved in teaching complicated topics in a compre- hensive and thoughtful way. Anil, Hansen, and Pranav navigate these waters master- fully, providing in-depth examples and sample code to guide you through advanced data modeling use cases. So, what are you waiting for? It’s time to take your career to the next level! What did you think about SAP HANA Advanced Data Modeling? Your comments and suggestions are the most useful tools to help us make our books the best they can be. Please feel free to contact me and share any praise or criticism you may have. Thank you for purchasing a book from SAP PRESS! Sarah Frazier Editor, SAP PRESS Rheinwerk Publishing Boston, MA sarahf@rheinwerk-publishing.com www.sap-press.com
Page 5
Notes on Usage This e-book is protected by copyright. By purchasing this e-book, you have agreed to accept and adhere to the copyrights. You are entitled to use this e-book for personal purposes. You may print and copy it, too, but also only for personal use. Sharing an electronic or printed copy with others, however, is not permitted, neither as a whole nor in parts. Of course, making them available on the Internet or in a company network is illegal as well. For detailed and legally binding usage conditions, please refer to the section Legal Notes. This e-book copy contains a digital watermark, a signature that indicates which person may use this copy:
Page 6
Imprint This e-book is a publication many contributed to, specifically: Editor Sarah Frazier Acquisitions Editor Kelly Grace Weaver Copyeditor Melinda Rankin Cover Design Graham Geary Photo Credit Shutterstock.com: 1578873/© Tomislav Forgo Production E-Book Kelly O’Callaghan Typesetting E-Book SatzPro, Krefeld (Germany) We hope that you liked this e-book. Please share your feedback with us and read the Service Pages to find out how to contact us. The Library of Congress has cataloged the printed edition as follows: Ankisettipalli, Anil Babu, author. SAP HANA advanced data modeling / Anil Babu Ankisettipalli, Hansen Chen, Pranav Wankawala. -- 1st edition. pages cm Includes index. ISBN 978-1-4932-1236-1 (print : alk. paper) -- ISBN 1-4932-1236-2 (print : alk. paper) -- ISBN 978-1-4932-1238-5 (print and ebook : alk. paper) -- ISBN 978-1-4932-1237-8 (ebook) 1. Computer simulation. 2. Databases . 3. SAP HANA (Electronic resource) I. Chen, Hansen, author. II. Wankawala, Pranav, author. III. Title. QA76.9.C65A55 2015 003’.3--dc23 2015030306 ISBN 978-1-4932-1236-1 (print) ISBN 978-1-4932-1237-8 (e-book) ISBN 978-1-4932-1238-5 (print and e-book) © 2016 by Rheinwerk Publishing, Inc., Boston (MA) 1st edition 2016
Page 7
We would like to thank all of our colleagues at the SAP Innovation Center – Silicon Valley, USA. All of our knowledge and findings have come from several projects that we have worked on together over the years. This book would not have been possible without all the knowledge sharing, brainstorming, and problem solving that we did together. Our attempt with this book is to extend our culture of collaboration, thought leadership, and innovation to a wider community. We would like to dedicate this book to this fantastic team with whom we are privileged to work with.
Page 8
(This page has no text content)
Page 9
9 Contents 1 SAP HANA Data Models ........................................................... 21 1.1 SAP HANA Database Architecture Overview .................................. 21 1.2 SAP HANA Modeling Paradigms .................................................... 22 1.2.1 Client and Data Connection ............................................. 23 1.2.2 Modeled Views ................................................................ 24 1.2.3 Stored Procedures ............................................................ 24 1.2.4 C++ (Application Function Libraries) ................................. 25 1.2.5 L Language ....................................................................... 25 1.2.6 R Language ...................................................................... 25 1.3 Information Views ......................................................................... 26 1.3.1 Attribute Views ................................................................ 26 1.3.2 Analytic Views ................................................................. 37 1.3.3 Calculation Views ............................................................. 52 1.4 Analytic Privileges ......................................................................... 67 1.4.1 Classical XML-Based Analytic Privilege ............................. 67 1.4.2 SQL-Based Analytic Privilege ............................................ 73 1.5 Stored Procedures ......................................................................... 75 1.5.1 SQLScript Procedures ....................................................... 75 1.5.2 L Procedures .................................................................... 81 1.5.3 R Procedures .................................................................... 82 1.6 Application Function Library .......................................................... 86 1.6.1 Business Function Library ................................................. 86 1.6.2 Predictive Analysis Library ................................................ 88 1.7 Summary ....................................................................................... 90 2 Modeling Complex Logic .......................................................... 93 2.1 Achieving Recursive Logic with Hierarchies .................................... 93 2.1.1 Creating Hierarchies with Tables ....................................... 94 2.1.2 Creating a Hierarchy in an Attribute or Calculation View ... 97 2.1.3 Hierarchy View Attributes ................................................ 100 2.2 Transposing Columns and Rows ..................................................... 110 2.2.1 Column-to-Row Transposition .......................................... 110 2.2.2 Row-to-Column Transposition .......................................... 116 2.2.3 Reversing a Matrix ........................................................... 118
Page 10
10 Contents 2.2.4 Merging Data from Multiple Records ............................... 121 2.2.5 Splitting Strings ................................................................ 122 2.3 Using cube() with Hierarchies ........................................................ 123 2.4 Calculating Running Total .............................................................. 127 2.5 Calculating Cumulative Sum .......................................................... 131 2.6 Filtering Data Based on Ranking .................................................... 134 2.6.1 Using a Subquery ............................................................. 134 2.6.2 Using Window Functions ................................................. 135 2.6.3 Manipulating Concatenated Virtual Columns .................... 136 2.6.4 Using a Rank Node in a Calculation View ......................... 137 2.7 Controlling Join Paths via Filters .................................................... 138 2.8 Full Outer Join in a Calculation View ............................................. 143 2.9 Making Dynamic Queries in a Stored Procedure ............................ 148 2.9.1 Changing Tables Dynamically ........................................... 148 2.9.2 Changing Filters Dynamically ............................................ 150 2.9.3 Changing Output Columns Dynamically ............................ 152 2.10 Showing History Records Side By Side ........................................... 153 2.11 Sample Data .................................................................................. 158 2.11.1 Using RAND() ................................................................... 158 2.11.2 Using $rowid$ .................................................................. 158 2.11.3 Using Identity Columns .................................................... 159 2.11.4 Using LIMIT/OFFSET ........................................................ 160 2.11.5 Using the TABLESAMPLE SYSTEM .................................... 160 2.12 Using a Vertical Union to Join Tables ............................................. 161 2.13 Sorting Records ............................................................................. 163 2.13.1 Sorting IP Addresses ......................................................... 163 2.13.2 Sorting with Exceptions .................................................... 166 2.13.3 Sorting with User-Defined Rules ....................................... 167 2.14 Finding Missing Values .................................................................. 168 2.14.1 Using the NOT IN Clause .................................................. 169 2.14.2 Using a Self-Join ............................................................... 170 2.14.3 Using a Vertical Union ...................................................... 171 2.14.4 Using Window Functions ................................................. 171 2.15 Using Window Functions for Complex Grouping ............................ 172 2.16 Joining Based on a Date Sequence ................................................. 178 2.17 Using a Nested Calculation View ................................................... 185 2.18 Summary ....................................................................................... 191
Page 11
Contents 11 3 Scaling for Large Datasets ........................................................ 193 3.1 Partitioning ................................................................................... 193 3.1.1 Round-Robin Partitioning ................................................. 194 3.1.2 Range Partitioning ............................................................ 194 3.1.3 Hash Partitioning ............................................................. 195 3.1.4 Two-Level Partitioning ..................................................... 197 3.2 Using Input Parameters to Enforce Pruning .................................... 198 3.3 Creating an Index .......................................................................... 201 3.4 Analyzing Query Performance with Tools ....................................... 205 3.4.1 Explain Plan ..................................................................... 205 3.4.2 Visualize Plan ................................................................... 207 3.4.3 Performance Trace ........................................................... 208 3.5 Enforcing Execution Paths ............................................................. 214 3.6 Using a Union with Constant Values Instead of a Join .................... 218 3.7 Manipulating Joins in an Analytic View .......................................... 224 3.7.1 Breaking a Union of Dimension Tables ............................. 225 3.7.2 Making Nonequi Joins ...................................................... 230 3.7.3 Modifying Tables .............................................................. 232 3.8 Time Traveling ............................................................................... 236 3.8.1 History Tables .................................................................. 237 3.8.2 Simulated History Tables .................................................. 240 3.9 Storing Temporary Data ................................................................. 243 3.10 Calculating Count Distinct ............................................................. 247 3.11 Using Cached Views ...................................................................... 250 3.11.1 Defining a Result Cache .................................................... 251 3.11.2 Defining a View Cache ..................................................... 254 3.12 Summary ....................................................................................... 258 4 Basic Predictive Modeling ......................................................... 259 4.1 Predictive Analytics Lifecycle in SAP HANA ................................... 259 4.1.1 Commonly Used Models .................................................. 261 4.1.2 Predictive Algorithms in SAP HANA ................................. 264 4.1.3 Application Function Library ............................................ 266 4.1.4 Business Example ............................................................. 269 4.2 Data Exploration ........................................................................... 270 4.2.1 Understanding Sales Data ................................................. 270 4.2.2 Correlation and Autocorrelation ....................................... 279 4.2.3 Deterministic Variables .................................................... 285
Page 12
12 Contents 4.3 Data Preparation ........................................................................... 291 4.3.1 Predictive Data Types ....................................................... 291 4.3.2 Cleaning and Preparing Data ............................................ 292 4.4 Modeling ....................................................................................... 297 4.4.1 Predictive Modeling Tasks ................................................ 297 4.4.2 Setting Control Parameters ............................................... 299 4.4.3 Creating and Maintaining Models ..................................... 299 4.4.4 Validating Models ............................................................ 299 4.4.5 Scoring Models ................................................................ 300 4.4.6 Business Example ............................................................. 300 4.5 Creating Models Using SAP Applications on SAP HANA ................ 308 4.5.1 Application Function Modeler .......................................... 308 4.5.2 SAP Predictive Analytics ................................................... 311 4.6 Summary ....................................................................................... 318 5 Advanced Predictive Modeling ................................................. 319 5.1 R Script Modeling and Design ....................................................... 319 5.1.1 SAP HANA and R Integration ........................................... 319 5.1.2 Data Considerations ......................................................... 321 5.1.3 Data Types and RLANG Script .......................................... 324 5.2 PAL Model Consumption ............................................................... 326 5.3 Real-Time Model Consumption vs. Batch Predictive Modeling ...... 329 5.3.1 Real-Time Model Execution ............................................. 329 5.3.2 Batch Predictive Model Execution .................................... 330 5.4 Impact of Data Partitions in Predictive Modeling ........................... 332 5.5 Using Multiple R Servers and Data Partitions ................................. 333 5.5.1 Predictive Analysis Library ................................................ 333 5.5.2 Using Multiple R Servers .................................................. 335 5.6 Modeling Using R and PAL Simultaneously .................................... 337 5.7 Summary ....................................................................................... 340 6 Simulations and Optimizations ................................................ 341 6.1 Case Study ..................................................................................... 341 6.2 Monte Carlo Simulation of Value-at-Risk ....................................... 342 6.2.1 Random Variable Generation ............................................ 343 6.2.2 Simulation Model and Process ......................................... 350 6.2.3 Avoiding Imperative Logic ................................................ 358
Page 13
Contents 13 6.3 Portfolio Optimization ................................................................... 363 6.3.1 Variance-Covariance Matrix .............................................. 365 6.3.2 Modeling for Optimization Constraints and Equations ...... 370 6.3.3 Executing Optimization Models ....................................... 379 6.4 Summary ....................................................................................... 380 The Authors .................................................................................................... 381 Index ............................................................................................................... 383 Service Pages .................................................................................................... I Legal Notes ...................................................................................................... III
Page 14
(This page has no text content)
Page 15
3 Preface SAP HANA is a database and, as such, stores data. For that data to have any mean- ing, it must be arranged into data models, maps that describe how specific ele- ments of data relate to each other. Once arranged, the data should be used by applications. The operations on this data structure could be simple calculations, complex machine learning techniques, or anything in between. Most often, the design of a data model and joins on the tables in a data model relate to the per- formance of a query or function processing in any database. SAP HANA can enable application requirements like business function calculations through logi- cal models used on top of data models. These requirements can range from sim- ple to complex calculations in distributed, scaled-out environments with billions of rows to process. With these calculation models, applications can also find meaningful data insights by executing machine learning or predictive algorithms. SAP HANA has both natively embedded predictive algorithms and integrations with R to offer flexibil- ity. As we move from predictive to simulation and optimization problems, the challenge of the database is to be versatile in order to perform various complex data structure operations. Target Audience This book expects the reader to be aware of in-memory databases and column- oriented databases, and have basic exposure to and hands-on experience with SAP HANA development artifacts. Preferably, the reader will also have basic SQL and data modeling knowledge. Advanced data modeling topics here start from basic calculations in straightforward data models and move to performing com- plex calculations and machine learning or predictive analytic tasks. This book expects readers to have basic knowledge of and experience with data science-ori- ented activities and to use such techniques in their regular activities.15
Page 16
PrefaceObjective The purpose of this book is to teach developers working in SAP HANA how to design complex data models that perform optimally. With a lot of flexibility in performing database tasks in SAP HANA, this book will help readers learn about the various modeling capabilities in SAP HANA, how to develop complex logic through these logical models, and how to scale for higher volumes of data. This advanced modeling book also covers predictive modeling capabilities in SAP HANA using various algorithm libraries and how to build complex modeling sce- narios using multiple types of algorithms together. Finally, we will look at per- forming complex processes (such as simulations and optimizations) in SAP HANA. Structure of this Book This book is organized into two sets of three chapters. The first set will cover data modeling of both physical and logical models and scenarios from simple to com- plex. The second set will move to predictive modeling, starting with basic predic- tive modeling and concluding with performing complex operations for simula- tions and optimizations. The following walks through details of the chapters ahead: Chapter 1: Types of SAP HANA Models This chapter gives an overview of all SAP HANA features and then explains the workflow to use SAP HANA Studio to leverage each feature. As this book is for developers who already have SAP HANA experience, we do not provide much explanation on basic concepts; instead, we focus on elements that usually con- fuse developers. This chapter covers the SAP HANA modeling paradigm, infor- mation views (including attribute views, analytic views, and calculation views), analytic privileges, stored procedures (including SQLScript procedures, L lan- guage procedures, and R language procedures), and the Application Function Library (including the Business Function Library and the Predictive Analysis Library). With the overall understanding gained in this chapter, developers can move on to other chapters to learn more about SAP HANA models and model- ing use cases. Chapter 2: Modeling Complex Logic This chapter explains how to use SAP HANA data models to represent complex business logic. As it is more flexible and efficient to leverage SAP HANA mod-16
Page 17
Prefaceeling features to depict complex logic than traditional SQL statements, devel- opers need to learn how to think in SAP HANA to solve complex problems. Chapter 3: Scaling for Large Datasets This chapter focuses on solutions for scaling large datasets in SAP HANA. Large datasets can hinder performance, which is a primary concern for many devel- opers. SAP HANA provides many features to handle performance, especially for large tables. We will introduce these features with examples based on our experience. Developers may need to know how to set up databases and models, design reporting strategies, and troubleshoot performance issues so as to make their applications run smoothly against large tables. Chapter 4: Basic Predictive Modeling In this chapter, we will introduce the predictive analytics lifecycle. We walk through how to execute lifecycle activities in SAP HANA and provide examples of how to execute correlations, autocorrelations, component analysis, time series algorithms, and forecast accuracy measurement, along with exploration and modeling in SAP HANA. The chapter then introduces various tools, such as the Application Function Modeler and predictive analytics applications in SAP HANA for performing data science-oriented tasks. Chapter 5: Advanced Predictive Modeling Now that you have learned about basic predictive modeling, this chapter looks at R’s integration with SAP HANA and how to design complex predictive mod- els that need to scale out in distributed environments. We also will look at using multiple components such as PAL and R together in single use case for machine learning activities. The chapter walks through stratification and sam- pling examples to reduce information transfer without losing the proportional distribution of data. Chapter 6: Simulations and Optimization You can use SAP HANA to design simulation and optimization models. This chapter explains how to perform random variable generation, matrix manipu- lation operations, and optimizations and simulations, using a case study. We hope this book provides an advanced look at all aspects of modeling and scal- ing for complex processing.17
Page 18
PrefaceReferences and Resources The following resources were used by the authors in the course of writing of this book and should be referred to for continued learning: SAP HANA SQL and System Views Reference http://help.sap.com/hana/sap_hana_sql_and_system_views_reference_en.pdf SAP HANA Master Guide http://help.sap.com/hana/sap_hana_master_guide_en.pdf SAP HANA Business Function Library (BFL) https://help.sap.com/hana/SAP_HANA_Business_Function_Library_BFL_en.pdf SAP HANA Predictive Analysis Library (PAL) http://help.sap.com/hana/sap_hana_predictive_analysis_library_pal_en.pdf SAP HANA R Integration Guide http://help.sap.com/hana/sap_hana_r_integration_guide_en.pdf SAP HANA Modeling Guide http://help.sap.com/hana/sap_hana_modeling_guide_en.pdf SAP HANA Troubleshooting and Performance Analysis Guide http://help.sap.com/hana/sap_hana_troubleshooting_and_performance_analysis_ guide_en.pdf An Introduction to R https://cran.r-project.org/doc/manuals/R-intro.pdf SAP HANA Modeling Overview http://saphanatutorial.com/sap-hana-modeling/ Building Advanced Data Models with SAP HANA http://scn.sap.com/docs/DOC-13267 SAP HANA SQLScript Reference http://help.sap.com/hana/sap_hana_sql_script_reference_en.pdf Acknowledgments We would like to thank Sarah Frazier, our editor for this book. For all three of us who set out on this journey of writing a book for the first time, rather than being just an editor, she mentored us on the nuances of authoring a book, which is very different from writing technical papers or publications that we are used to as part of the software development process. She had to understand three different writ- ing styles and bring consistency to the content so that you, our readers, get a product of high quality.18
Page 19
PrefaceDaisuke Tsuru is a system engineer for Nomura Research Institute in Tokyo, Japan. As part of an exchange program he has been working at SAP since 2014. He has actively worked in developing the portfolio optimization and simulation case study implementation used in Chapter 6. We would like to thank him for his efforts in developing this technique. Anil Babu Ankisettipalli Hansen Chen Pranav Wankawala Palo Alto, California — October 201519
Page 20
(This page has no text content)
The above is a preview of the first 20 pages. Register to read the complete e-book.

Recommended for You

Loading recommended books...
Failed to load, please try again later

Tip the Site

Scan the WeChat Pay or Alipay code to tip. No login required.

WeChat Pay
Alipay
← Back to List