Tải bản đầy đủ (.pdf) (397 trang)

SAP HANA DEVELOPER GUIDE doc

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (8.62 MB, 397 trang )

PUBLIC
SAP HANA Appliance Software SPS 05
Document Version: 1.1 - 2012-12-21
SAP HANA Developer Guide
Table of Contents
1 Document History 9
2 Overview 10
3 SAP HANA 11
3.1 The SAP HANA In-Memory Database 11
3.1.1 Columnar Data Storage 11
3.1.2 Parallel Processing 12
3.1.3 Simplifying Applications 12
3.2 SAP HANA Database Architecture 13
3.3 SAP HANA Extended Application Services 14
3.4 Refactoring SAP HANA Based Applications 17
4 SAP HANA as a Development Platform 18
4.1 Developer Scenarios 18
4.1.1 Scenario: Developing Native SAP HANA Applications 19
4.1.2 Scenario: Using Database Client Interfaces 20
4.2 Development Objects 21
4.3 Repository 23
4.4 SAP HANA Studio 25
4.4.1 Modeler Perspective 26
4.4.2 SAP HANA Development Perspective 27
4.4.3 Debug Perspective 32
4.4.4 Administration Console Perspective 33
4.5 Getting Started 34
4.5.1 Adding a System 35
5 Setting Up Your Application 36
5.1 Setting up Delivery Units 37
5.1.1 Maintaining the Delivery-Unit Vendor ID 37


5.1.2 SAP HANA Delivery Unit Naming Conventions 38
5.1.3 Creating a Delivery Unit 38
5.2 Using SAP HANA Projects 39
5.2.1 SAP HANA Repository: Workspaces 40
5.2.2 Creating a Repository Workspace 40
5.2.3 SAP HANA Studio Projects 41
5.2.4 Creating a Project for SAP HANA XS 42
5.2.5 Sharing a Project for SAP HANA XS 42
2
P U BL I C
©
2012 SAP AG. All rights reserved.
SAP HANA Developer Guide
Table of Contents
5.2.6 Importing a Project in SAP HANA XS 43
5.3 Maintaining Repository Packages 44
5.3.1 SAP HANA Repository Packages and Namespaces 45
5.3.2 Defining Repository Package Privileges 48
5.3.3 Creating a Package 48
5.3.4 Defining a Package Hierarchy 49
5.4 Creating the Application Descriptors 51
5.4.1 The SAP HANA XS Application Descriptor 51
5.4.2 Create an Application Descriptor File 52
5.4.3 The Application-Access File 52
5.4.4 Application-Access File Keyword Options 55
5.4.5 Application-Access URL Rewrite Rules 59
5.4.6 Enabling Access to SAP HANA XS Application Packages 61
5.4.7 The Application-Privileges File 63
5.4.8 Create an SAP HANA XS Application Privileges File 64
5.5 Tutorial: My First SAP HANA Application 65

5.5.1 Open the Development Perspective 65
5.5.2 Add a System 67
5.5.3 Add a Workspace 69
5.5.4 Add a Project 70
5.5.5 Share Your Project 71
5.5.6 Write Server-Side JavaScript 73
5.5.7 Retrieve Data 75
6 Setting Up the Persistence Model 77
6.1 Schema 78
6.2 Creating Schemas 79
6.3 Tables 80
6.4 Table Configuration Schema 81
6.5 Creating Tables 85
6.6 Sequences 86
6.7 Creating Sequences 87
6.8 SQL Views 88
6.9 Creating SQL Views 89
6.10 Data Provisioning Using Table Import 90
6.10.1 Table-Import Model 91
6.10.2 Table-Import Data 91
6.10.3 Table-Import Extensions 92
6.10.4 Table-Import Configuration-File Syntax 92
6.11 Importing Data Using Table Import 93
6.12 Using Imported Table Data in SAP HANA 95
6.13 Using Imported Table Data in an SAP HANA XS Application 96
SAP HANA Developer Guide
Table of Contents
P UBL I C
©
2012 SAP AG. All rights reserved.

3
6.14 Extending a Table Import 98
7 Setting Up the Analytic Model 100
7.1 Setting Up the Modeling Environment 102
7.1.1 Setting Modeler Preferences 102
7.1.2 Configuring the Import Server 104
7.1.3 Importing Table Definitions 104
7.1.4 Loading Data into Tables 106
7.1.5 Copying Content Delivered by SAP 108
7.1.6 Mapping the Authoring Schema to the Physical Schema 109
7.1.7 Generating Time Data 111
7.2 Creating Views 111
7.2.1 Attributes and Measures 111
7.2.2 Attribute Views 113
7.2.3 Creating Attribute Views 113
7.2.4 Analytic Views 117
7.2.5 Creating Analytic Views 118
7.2.6 Calculation Views 124
7.2.7 Creating Calculation Views 125
7.2.8 Assigning Variables 132
7.2.9 Creating Input Parameters 134
7.2.10 Creating Hierarchies 136
7.2.11 Using Currency and Unit of Measure 139
7.2.12 Activating Objects 141
7.3 Creating Decision Tables 142
7.3.1 Changing the Layout of a Decision Table 148
7.3.2 Using Parameters in a Decision Table 148
7.4 Managing Object Versions 149
7.4.1 Switching Ownership of Inactive Objects 149
7.4.2 Toggling Versions of Content Objects 150

7.4.3 Viewing Version History of Content Objects 151
7.5 Working with Objects 151
7.5.1 Managing Layout 151
7.5.2 Filtering Packages and Objects 151
7.5.3 Refactoring Objects 152
7.5.4 Validating Models 153
7.5.5 Generating Object Documentation 153
7.5.6 Enabling Multilanguage Support for Objects 154
7.5.7 Checking Model References 154
7.5.8 Viewing the Job Log 155
7.5.9 Maintaining Search Attributes 155
7.5.10 Previewing Data of Content Objects 155
4
P UBL I C
©
2012 SAP AG. All rights reserved.
SAP HANA Developer Guide
Table of Contents
7.5.11 Functions used in Expressions 156
7.5.12 Searching Tables, Models and Column Views 161
7.5.13 Setting Keyboard Shortcuts 162
7.5.14 Copying an Object 163
7.6 Importing BW Objects 163
8 Developing Procedures 167
8.1 Editing SQLScript 168
8.1.1 Defining Local Table Types in Procedures 170
8.2 Debugging SQLScript 170
8.3 Developing Procedures in the Modeler Editor 172
9 Defining Web-based Data Access 174
9.1 Data Access with OData in SAP HANA XS 174

9.1.1 OData in SAP HANA XS 174
9.1.2 Defining the Data an OData Service Exposes 175
9.1.3 OData Service Definitions 176
9.1.4 Creating an OData Service Definition 178
9.1.5 Tutorial: Using the OData Interface 179
9.1.6 OData Service-Definition Examples 181
9.1.7 OData Service Definition Language Syntax 194
9.1.8 OData Service Definition: SQL-EDM Type Mapping 196
9.1.9 OData URI Parameters, Query Options, and Features 197
9.1.10 OData Security Considerations 213
9.2 Data Access with XMLA in SAP HANA XS 213
9.2.1 XML for Analysis (XMLA) 213
9.2.2 XMLA Service Definition 214
9.2.3 XMLA Security Considerations 215
9.2.4 Multidimensional Expressions (MDX) 215
9.2.5 MDX Functions 216
9.2.6 MDX Extensions 219
9.2.7 Defining the Data an XMLA Service Exposes 222
9.2.8 Creating an XMLA Service Definition 222
10 Writing Server-Side JavaScript Code 224
10.1 Data Access with JavaScript in SAP HANA XS 224
10.2 Writing JavaScript Code 224
10.2.1 Server-Side JavaScript in SAP HANA XS 224
10.2.2 JavaScript Editor 225
10.2.3 Server-Side JavaScript Security Considerations 226
10.2.4 Writing Server-Side JavaScript Application Code 231
10.3 Writing JavaScript Libraries 232
SAP HANA Developer Guide
Table of Contents
P UBL I C

©
2012 SAP AG. All rights reserved.
5
10.3.1 Server-Side JavaScript Libraries 232
10.3.2 Writing Server-Side JavaScript Libraries 233
10.3.3 Importing Server-Side JavaScript Libraries 233
10.4 Server-Side JavaScript APIs 234
10.5 The SQL Connection Configuration File 235
10.6 Tracing JavaScript 237
10.6.1 Server-Side JavaScript Tracing 237
10.6.2 Tracing Server-Side JavaScript Applications 237
10.6.3 Viewing Server-Side JavaScript Application Trace Files 238
10.7 Debugging JavaScript 238
10.7.1 Opening a Port for JavaScript Debugging 240
11 Building UIs 242
11.1 Building UIs with SAPUI5 242
11.1.1 Installing SAPUI5 Application Development Tools 242
11.1.2 Creating an SAPUI5 Application 243
11.1.3 Supporting Translation 247
11.2 Using UI Integration Services 247
11.2.1 Creating an Application Site 248
11.2.2 Creating a Widget 248
11.2.3 Designing an Application Site 249
11.2.4 Developing Widgets 250
12 Enabling Search 258
12.1 Creating Full Text Indexes 258
12.1.1 Full Text Index Types 260
12.1.2 Synchronization 263
12.1.3 Text Analysis 265
12.1.4 Dropping Full Text Indexes 269

12.1.5 Altering Full Text Index Parameters 269
12.1.6 Full Text Index Parameters 270
12.2 Building SQL Search Queries 275
12.2.1 Search Queries with CONTAINS 275
12.2.2 EXACT Search 278
12.2.3 LINGUISTIC Search 279
12.2.4 FUZZY Search 279
12.3 Building Search Apps 331
12.3.1 Introduction to the UI Toolkit for Info Access 331
12.3.2 Installing the Service and the Toolkit 332
12.3.3 Getting to Know the Demo App 333
12.3.4 Getting to Know the Demo HTML 334
12.3.5 Preparing Your Source Data 335
6
P UBL I C
©
2012 SAP AG. All rights reserved.
SAP HANA Developer Guide
Table of Contents
12.3.6 Connecting Your Source Data 337
12.3.7 Defining the Page Layout 338
12.3.8 Configuring the Widgets 338
12.3.9 Defining the Layout of Result Lists and Details 342
13 Setting Up Roles and Authorizations 343
13.1 The Authorization Model 343
13.2 Authentication Overview 344
13.3 Roles 344
13.3.1 Roles 345
13.3.2 Roles as Repository Objects 346
13.3.3 Creating Roles in the Repository 347

13.4 Privileges 352
13.4.1 System Privileges 352
13.4.2 Object Privileges 352
13.4.3 Package Privileges 353
13.4.4 Analytic Privileges 355
13.4.5 Creating Analytic Privileges 364
13.4.6 Granting Privileges to Users 368
13.5 Application Access 369
14 Implementing Lifecycle Management 371
14.1 SAP HANA Delivery Units 371
14.2 The SAP HANA Delivery-Unit Lifecycle 371
14.3 Exporting Delivery Units 372
14.4 Importing Delivery Units 374
14.5 Translating Delivery Units 375
14.5.1 SAP HANA Delivery-Unit Translation Details 376
14.5.2 Maintaining Translation Details 376
15 Using Database Client Interfaces 378
15.1 Connecting via ODBC 378
15.1.1 Using the User Store 379
15.1.2 Testing the ODBC Installation 380
15.2 Connecting via JDBC 381
15.2.1 Tracing JDBC Connections 382
15.2.2 Valid Java-to-SQL Conversions 384
15.3 Connecting via ODBO 385
15.3.1 Connecting with Microsoft Excel 385
15.3.2 Multidimensional Expressions (MDX) 388
15.3.3 MDX Functions 389
15.3.4 MDX Extensions 393
SAP HANA Developer Guide
Table of Contents

P UBL I C
©
2012 SAP AG. All rights reserved.
7
16 SAP HANA Developer References 396
8
P U BL I C
©
2012 SAP AG. All rights reserved.
SAP HANA Developer Guide
Table of Contents
1 Document History
The document history includes all versions of the document that have been published.
Version Date SAP HANA Revision Description
1.1 21 Dec 2012 47 References to the
following have been
added:
 Sections 7.2.3,
Creating Attribute
Views
and 7.2.5,
Creating Analytic
Views
have been
updated for Label
Mapping
functionality.
 Section 7.6,
Importing BW Objects
has been updated

with the support to
import role based
authorizations into
the Modeler as
analytic privileges.
 Section 8.1.1,
Defining
Local Table Types in
Procedures
.
 Section 11.2,
Using UI
Integration Services
.
SAP HANA Developer Guide
Document History
P UBL I C
©
2012 SAP AG. All rights reserved.
9
2 Overview
This guide presents a developers view of SAP HANA
®
. It explains how to use the SAP HANA development tools to
create comprehensive analytical models and to build applications with SAP HANA's programmatic interfaces and
integrated development environment, including to develop native code that runs inside SAP HANA.
The guide is organized as follows:

SAP HANA
[page 11] describes the capabilities of SAP HANA.


SAP HANA as a Development Platform
[page 18] describes the main developer scenarios, the development
process and the development environment.

Setting Up Your Application
[page 36] describes how to get started developing SAP HANA applications.
Most of the remaining chapters explain how to develop various SAP HANA development objects.
Note: Application development with SAP HANA Extended Application Services (SAP HANA XS) is
currently only available as an SAP-led project solution, for pre-approved customers and partners. This
applies to server-side JavaScript programming, support for ODATA and XMLA, Web server features and
the Web application development environment. For more information, see
SAP Note 1779803
.
Audience
This guide is aimed at two developer roles:
 Modeler: This person, often a business/data analyst or database expert, is concerned with the definition of
the model and schemas that will be used in SAP HANA, the specification and definition of tables, views,
primary keys, indexes, partitions and other aspects of the layout and inter-relationship of the data in SAP
HANA.
The data modeler is also concerned with designing and defining authorization and access control, through the
specification of privileges, roles and users.
The modeler generally uses the Administration Console and Modeler perspectives and tools of the SAP HANA
studio.
 Application Programmer: The programmer is concerned with building SAP HANA applications, which could
take many forms but are designed based on the model-view-controller architecture. Programmers develop
the code for:
 View, which could run inside a browser or on a mobile device
 Controller, which typically runs in the context of an application server
 Model, which interacts closely with the data model, performs efficient queries, and may be developed to

run within the SAP HANA data engine, using embedded procedures or libraries
The programmer generally uses the
SAP HANA Development perspective and tools of the SAP HANA studio.
10
P U BL I C
©
2012 SAP AG. All rights reserved.
SAP HANA Developer Guide
Overview
3 SAP HANA
SAP HANA is an in-memory data platform that is deployable as an appliance or in the cloud. At its core, it is an
innovative in-memory relational database management system that makes full use of the capabilities of current
hardware to increase application performance, to reduce cost of ownership, and to enable new scenarios and
applications that were not possible before.
With SAP HANA, you have the opportunity to build applications that integrate the business control logic and the
database layer with unprecedented performance. As a developer, one of the key questions is how you can
minimize data movements. The more you can do directly on the data in memory next to the CPUs, the better the
application will perform.
3.1 The SAP HANA In-Memory Database
SAP HANA was designed to run on modern, distributed computers built out of multi-core CPUs (multiple CPUs on
one chip) with fast communication between processor cores, and containing terabytes of main memory. With
SAP HANA, all data is available in main memory, which completely avoids the performance penalty of disk I/O.
Either disk or solid-state drives are still required for permanent persistency in the event of a power failure or some
other catastrophe. This does not slow down performance, however, because the required backup operations to
disk can take place asynchronously as a background task.
3.1.1 Columnar Data Storage
A database table is conceptually a two-dimensional data structure organized in rows and columns. Computer
memory, in contrast, is organized as a linear structure. A table can be represented in row-order or column-order.
A row-oriented organization stores a table as a sequence of records. Conversely, in column storage the entries of
a column are stored in contiguous memory locations. SAP HANA supports both, but is particularly optimized for

column-order storage.
Columnar data storage allows highly efficient compression. Especially if a column is sorted, there will normally be
repeated adjacent values. SAP HANA employs highly efficient compression methods, such as run-length
encoding, cluster coding and dictionary coding. With dictionary encoding, columns are stored as sequences of bit-
coded integers. That means that a check for equality can be executed on the integers (for example during scans
or join operations). This is much faster than comparing, for example, string values.
SAP HANA Developer Guide
SAP HANA
P UBL I C
©
2012 SAP AG. All rights reserved.
11
Columnar storage, in many cases, eliminates the need for additional index structures. Storing data in columns is
functionally similar to having a built-in index for each column. The column scanning speed of the in-memory
column store and the compression mechanisms  especially dictionary compression  allow read operations with
very high performance. In many cases it will not be required to have additional indexes. Eliminating additional
indexes reduces complexity and eliminates effort for defining and maintaining metadata.
3.1.2 Parallel Processing
SAP HANA was designed from the ground up to perform its basic calculations (such as analytic joins, scans and
aggregations) in parallel, often using hundreds of cores at the same time, fully utilizing the available computing
resources of distributed systems.
With columnar data, operations on single columns, such as searching or aggregations, can be implemented as
loops over an array stored in contiguous memory locations. Such an operation has high spatial locality and can
efficiently be executed in the CPU cache. With row-oriented storage, the same operation would be much slower
because data of the same column is distributed across memory and the CPU is slowed down by cache misses.
Compressed data can be loaded into the CPU cache faster. This is because the limiting factor is the data transport
between memory and CPU cache, and so the performance gain will exceed the additional computing time needed
for decompression.
Column-based storage also allows execution of operations in parallel using multiple processor cores. In a column
store, data is already vertically partitioned. This means that operations on different columns can easily be

processed in parallel. If multiple columns need to be searched or aggregated, each of these operations can be
assigned to a different processor core. In addition, operations on one column can be parallelized by partitioning
the column into multiple sections that can be processed by different processor cores.
3.1.3 Simplifying Applications
Traditional business applications often use materialized aggregates to increase performance. These aggregates
are computed and stored either after each write operation on the aggregated data, or at scheduled times. Read
operations read the materialized aggregates instead of computing them each time they are required.
12
P UBL I C
©
2012 SAP AG. All rights reserved.
SAP HANA Developer Guide
SAP HANA
With a scanning speed of several gigabytes per millisecond, SAP HANA makes it possible to calculate aggregates
on large amounts of data on-the-fly with high performance. This eliminates the need for materialized aggregates
in many cases, simplifying data models, and correspondingly the application logic. Furthermore, with on-the fly
aggregation, the aggregate values are always up-to-date unlike materialized aggregates that may be updated only
at scheduled times.
3.2 SAP HANA Database Architecture
A running SAP HANA system consists of multiple communicating processes (services). The following shows the
main SAP HANA database services in a classical application context.
Such traditional database applications use well-defined interfaces (for example, ODBC and JDBC) to
communicate with the database management system functioning as a data source, usually over a network
connection. Often running in the context of an application server, these traditional applications use Structured
Query Language (SQL) to manage and query the data stored in the database.
The main SAP HANA database management component is known as the index server. The index server contains
the actual data stores and the engines for processing the data. The index server processes incoming SQL or MDX
statements in the context of authenticated sessions and transactions.
SAP HANA Developer Guide
SAP HANA

P UBL I C
©
2012 SAP AG. All rights reserved.
13
The SAP HANA database has its own scripting language named SQLScript. The motivation for SQLScript is to
embed data-intensive application logic into the database. Classical applications tend to offload only very limited
functionality into the database using SQL. This results in extensive copying of data from and to the database, and
in programs that slowly iterate over huge data loops and are hard to optimize and parallelize. SQLScript is based
on side-effect free functions that operate on tables using SQL queries for set processing, and is therefore
parallelizable over multiple processors.
In addition to SQLScript, SAP HANA supports a framework for the installation of specialized and optimized
functional libraries, which are tightly integrated with different data engines of the index server. Two of these
functional libraries are the SAP HANA Business Function Library (BFL) and the SAP HANA Predictive Analytics
Library (PAL). BFL and PAL functions can be called directly from within SQLScript.
SAP HANA also supports the development of programs written in the popular statistics language R.
SQL and SQLScript are implemented using a common infrastructure of built-in data engine functions that have
access to various meta definitions, such as definitions of relational tables, columns, views, and indexes, and
definitions of SQLScript procedures. This metadata is stored in one common catalog.
The database persistence layer is responsible for durability and atomicity of transactions. It ensures that the
database can be restored to the most recent committed state after a restart and that transactions are either
completely executed or completely undone.
The index server uses the preprocessor server for analyzing text data and extracting the information on which the
text search capabilities are based. The name server owns the information about the topology of a SAP HANA
system. In a distributed system, the name server knows where the components are running and which data is
located on which server. The statistics server collects information about status, performance and resource
consumption from the other servers in the system. Monitoring clients, such as the SAP HANA studio, access the
statistics server to get the status of various alert monitors. The statistics server also provides a history of
measurement data for further analysis.
Related Links
SAP HANA SQLScript Reference

SAP HANA Business Function Library (BFL) Reference
SAP HANA Predictive Analysis Library (PAL) Reference
SAP HANA R Integration Guide
3.3 SAP HANA Extended Application Services
Traditional database applications use interfaces such as ODBC and JDBC with SQL to manage and query their
data. The following illustrates such applications using the common Model-View-Controller (MVC) development
architecture.
14
P UBL I C
©
2012 SAP AG. All rights reserved.
SAP HANA Developer Guide
SAP HANA
SAP HANA greatly extends the traditional database server role. SAP HANA functions as a comprehensive
platform for the development and execution of native data-intensive applications that run efficiently in SAP HANA,
taking advantage of its in-memory architecture and parallel execution capabilities.
By restructuring your application in this way, not only do you gain from the increased performance due to the
integration with the data source, you can effectively eliminate the overhead of the middle-tier between the user-
interface (the view) and the data-intensive control logic, as shown in the following figure.
In support of this data-integrated application paradigm, SAP HANA Extended Application Services provides a
comprehensive set of embedded services that provide end-to-end support for Web-based applications. This
includes a lightweight web server, configurable OData support, server-side JS execution and, of course, full
access to SQL and SQLScript.
These SAP HANA Extended Application Services are provided by the SAP HANA XS server, which provides
lightweight application services that are fully integrated into SAP HANA. It allows clients to access the SAP HANA
system via HTTP. Controller applications can run completely natively on SAP HANA, without the need for an
additional external application server.The following shows the SAP HANA XS server as part of the SAP HANA
system.
SAP HANA Developer Guide
SAP HANA

P UBL I C
©
2012 SAP AG. All rights reserved.
15
The application services can be used to expose the database data model, with its tables, views and database
procedures, to clients. This can be done in a declarative way using OData services or by writing native application-
specific code that runs in the SAP HANA context . Also, you can use SAP HANA XS to build dynamic HTML5 UI
applications.
In addition to exposing the data model, SAP HANA XS also hosts system services that are part of the SAP HANA
system. The search service is an example of such a system application. No data is stored in the SAP HANA XS
server itself. To read tables or views, to modify data or to execute SQLScript database procedures and
calculations, it connects to the index server (or servers, in case of a distributed system).
Note: Application development with SAP HANA Extended Application Services (SAP HANA XS) is
currently only available as an SAP-led project solution, for pre-approved customers and partners. This
applies to server-side JavaScript programming, support for ODATA and XMLA, Web server features and
the Web application development environment. For more information, see
SAP Note 1779803
.
Related Links
Building UIs with SAPUI5
[page 242]
This section provides introductory information about UI development toolkit for HTML5.
Enabling Search
[page 258]
With a SAP HANA database, your users will want to search tables and views much like they would when
searching for information on the Internet. In SAP HANA, you can either directly query data using SQL queries
or you can build search apps using a UI toolkit.
16
P U BL I C
©

2012 SAP AG. All rights reserved.
SAP HANA Developer Guide
SAP HANA
3.4 Refactoring SAP HANA Based Applications
The possibility to run application-specific code in SAP HANA raises the question: What kind of logic should run
where? Clearly, data-intensive and model-based calculations must be close to the data and, therefore, need to be
executed in the index server, for instance, using SQLScript or the code of the specialized functional libraries.
The presentation (view) logic runs on the client  for example, as an HTML5 application in a Web browser or on a
mobile device.
Native application-specific code, supported by SAP HANA Extended Application Services, can be used to provide
a thin layer between the clients on one side, and the views, tables and procedures in the index server on the other
side. Typical applications contain, for example, control flow logic based on request parameters, invoke views and
stored procedures in the index server, and transform the results to the response format expected by the client.
Such applications can also send emails and consume external HTTP-based services.
The communication between the SAP HANA XS server and index server is optimized for high performance.
However, performance is not the only reason why the SAP HANA XS server was integrated into SAP HANA. It also
leads to simplified administration and a better development experience.
The SAP HANA XS server completes SAP HANA to make it a comprehensive development platform. With the SAP
HANA XS server, developers can write SAP HANA-based applications that cover all server-side aspects, such as
tables and database views, database procedures, server-side control logic, integration with external systems, and
provisioning of HTTP-based services. The integration of the SAP HANA XS server into the SAP HANA system also
helps to reduce cost of ownership, as all servers are installed, operated and updated as one system.
SAP HANA Developer Guide
SAP HANA
P UBL I C
©
2012 SAP AG. All rights reserved.
17
4 SAP HANA as a Development
Platform

To simplify and support the development of HANA Based applications, SAP HANA serves as the integrated
development environment (IDE) for developing and delivering these SAP HANA applications.
Built around the Eclipse-based SAP HANA studio the SAP HANA IDE supports integrated and collaborative
development, debugging and deployment of applications that use native database procedures for data
processing, server-side JavaScript for control and an HTML5 SDK for the development of user interface
representation.
The design-time environment's central component is the SAP HANA repository, which stores and manages all
design-time objects. The following figure illustrates the principle of co-development with SAP HANA.
Using the HANA studio on your workstation, you design and create development objects such as data models or
server-side code files, and then store, manage and share them with other developers, by interacting with the SAP
HANA repository. The repository enables teams to work together on a set of development objects, and ultimately
turn them into runtime objects which can be used by clients or other applications. The repository provides the
basis for concepts like namespaces (through packages), transport and delivery support.
4.1 Developer Scenarios
The possibility to run application specific code in SAP HANA creates several possibilities for developing SAP
HANA based applications, representing various integration scenarios, and corresponding development
processes.
Broadly, we distinguish SAP HANA based applications into two broad categories:
 Web-based scenarios that take full advantage of the SAP HANA Extended Application Services. In these
scenarios, clients access SAP HANA data using standard OData or XMLA interfaces, or directly use a Web-
based GUI that was developed using the SAPUI5 toolkit, and that uses custom-developed server-side
JavaScript, as well as native SQLScript procedures.
 Traditional client-based scenarios, where an external application accesses the SAP HANA data model (tables,
analytic views, etc.) via client interfaces such as ODBC, ODBO and JDBC, and only uses SQL and native
SQLScript procedures.
18
P UBL I C
©
2012 SAP AG. All rights reserved.
SAP HANA Developer Guide

SAP HANA as a Development Platform
In either case, as a developer you need to understand the SAP HANA development environment, which enables
you to design and develop your data and analytical models, and your other HANA-based development objects in
the form of portable and deployable delivery units.
Common activities include:
Table 1: Common Activities
Activity More Information
Setting up your development environment.
Setting Up Your Application
[page 36]
Setting up your schema and tables.
Setting Up the Persistence Model
[page 77]
Setting up views of your data.
Setting Up the Analytic Model
[page 100]
Developing procedures for data-intensive logic.
Developing Procedures
[page 167]
Setting up roles and authorizations.
99bd0c457120482bac3cb4ffa6122534.ditamap
Managing the delivery of your application.
SAP HANA Delivery Units
[page 371]
For these activites, you will want to keep handy the following references:

SAP HANA SQL Reference
, to help you writing SQL statements within procedures and from your server-side
JavaScript.


SAP HANA SQLScript Reference
, to help you if you are writing procedures.
The next two sections describes the main scenarios and what activities you may need to perform for them.
4.1.1 Scenario: Developing Native SAP HANA Applications
Here, you want to create a Web-based scenario that takes full advantage of SAP HANA Extended Application
Services. In this scenario, clients access SAP HANA data using standard OData or XMLA interfaces, or directly use
a Web-based GUI that was developed using the SAPUI5 toolkit, and that uses custom-developed server-side
JavaScript, as well as native SQLScript procedures.
SAP HANA Developer Guide
SAP HANA as a Development Platform
P UBL I C
©
2012 SAP AG. All rights reserved.
19
For this scenario, you may need to perform the following activities:
Table 2: Developing Native SAP HANA Applications
Activity More Information
Develop server-side JavaScript for control logic.
Writing Server-Side JavaScript Code
[page 224]
Define OData data interfaces.
Data Access with OData in SAP HANA XS
[page 174]
Define XMLA data interfaces
Data Access with XMLA in SAP HANA XS
[page 213]
How to build HTML pages with SAPUI5.
Building UIs with SAPUI5
[page 242]
You will also want to keep handy the following references:


SAP HANA SQL Reference
, to help you write SQL statements within procedures and from your server-side
JavaScript.

SAP HANA XS JavaScript Reference
, to help you use the SAP HANA XS JavaScript API.
For a list of all references, see
SAP HANA Developer References
[page 396].
4.1.2 Scenario: Using Database Client Interfaces
Here, you want to build an application outside of SAP HANA, for example, within SAP NetWeaver, that accesses
the SAP HANA data model (for example, tables and analytic views) via client interfaces such as ODBC, ODBO and
JDBC, and only uses SQL and native SQLScript procedures.
20
P U BL I C
©
2012 SAP AG. All rights reserved.
SAP HANA Developer Guide
SAP HANA as a Development Platform
For this scenario, you may need to perform the following activities:
Table 3: Using Database Client Interfaces
Activity More Information
Installing and using the SAP HANA client interfaces
Using Database Client Interfaces
[page 378]
Developing procedures for data-intensive logic.
Developing Procedures
[page 167]
You will also want to keep handy several references:


SAP HANA SQL Reference
, to help you write SQL statements.
For information on MDX in SAP HANA, see
MDX Functions
[page 216].

SAP HANA SQLScript Reference
, to help you if you are writing procedures.
For a list of all references, see
SAP HANA Developer References
[page 396].
4.2 Development Objects
The design-time building blocks of your SAP HANA applications are called development objects. Some of these
development objects, such as projects and packages, are concepts that help you structure your application.
Others, like schemas, table definitions, analytical and attribute views, help you organize the structure of your data.
Procedures and server-side JavaScript code are the backbone of the SAP HANA application. Other types of
development objects help you control the access to runtime objects.
Understanding the different development objects and their use is one of the main objectives of this guide.
The following are the building blocks for an SAP HANA application, showing the file extension and where to get
information for building it:
SAP HANA Developer Guide
SAP HANA as a Development Platform
P UBL I C
©
2012 SAP AG. All rights reserved.
21
Table 4: Application Building Blocks
Object Description File Extension More Information
Structure

Project An Eclipse project for developing your
application or part of an application.
The .project file can be stored in the SAP
HANA repository.
.project
SAP HANA Studio Projects
[page 41]
Package A container in the repository for
development objects.
Packages are
represented by
folders.
Maintaining Repository
Packages
[page 44]
Modeling Data
Schema A database schema for organizing database
objects.
.hdbschema
Schema
[page 78]
Table A database table. .hdbtable
Tables
[page 80]
SQL View A virtual table based on a SQL query. .hdbview
SQL Views
[page 88]
Attribute,
Analytic and
Calculation

View
A view created with modeling tools and
designed to model a business use case.
Created with the
Navigator view.
Setting Up the Analytic
Model
[page 100]
Decision Table A database table used to define business
rules, for example, for validating data.
Creating Decision Tables
[page 142]
Analytic
Privilege
A set of rules that restricts users to seeing
only a subset of data in a table or view.
Creating Analytic Privileges
[page 364]
Sequence A set of unique numbers, for example, for
use as primary keys for a specific table.
.hdbsequence
Sequences
[page 86]
Procedure A database function for performing
complex and data-intensive business logic
that cannot be performed with standard
SQL.
.procedure
Developing Procedures
[page 167]

Web Access
Application
Descriptor
A file in a repository package that defines a
root folder of a native SAP HANA
application. All files in that package are
available to be called via URL.
.xsapp
Creating the Application
Descriptors
[page 51]
Application
Access File
A file that defines permissions for a native
SAP HANA application, that is, permissions
for accessing and running objects in the
package.
.xsaccess
Enabling Access to SAP
HANA XS Application
Packages
[page 61]
Application
Privilege
A file that defines a privilege related to an
SAP HANA Extended Application Services
.xsprivileges
The Application-Privileges
File
[page 63]

22
P UBL I C
©
2012 SAP AG. All rights reserved.
SAP HANA Developer Guide
SAP HANA as a Development Platform
Object Description File Extension More Information
application, for example, the right to start or
administer the application.
Server-Side
JavaScript
Code
JavaScript code that can run in SAP HANA
Extended Application Services and that can
be accessed via URL.
.xsjs
Writing Server-Side
JavaScript Application
Code
[page 231]
Server-Side
JavaScript
Library
JavaScript code that can run in SAP HANA
Extended Application Services but cannot
be accessed via URL. The code can be
imported into an .xsjs code file.
.xsjslib
OData
Descriptor

A file that defines an OData service that
exposes SAP HANA data.
.xsodata
Data Access with OData in
SAP HANA XS
[page 174]
XMLA
Descriptor
A file that defines an XMLA service that
exposes SAP HANA data.
.xsxmla
Data Access with XMLA in
SAP HANA XS
[page 213]
SQL Connection
Configuration
A file that enables execution of SQL
statements from inside server-side
JavaScript code with credentials that are
different than those of the requesting user.
.xssqlcc
The SQL Connection
Configuration File
[page
235]
Other
Role A file that defines an SAP HANA role.
.hdbrole
Creating Roles in the
Repository

[page 347]
Search Rule Set A file that defines a set of rules for use with
fuzzy searches. The rules help decide what
is a valid match in a search.
.searchruleset
Search Rules
[page 324]
Resource
Bundle
A file for defining translatable UI texts for an
application.
.hdbtextbundle
Creating an SAPUI5
Application
[page 243]
Application Site A file that defines an application site.
.xsappsite
Creating an Application
Site
[page 248]
Widget A file that defines a standalone SAP HANA
application for the purpose of integration
into an application site. A file that defines a
standalone SAP HANA application for the
purpose of integration into an application
site.
.xswidget
Creating a Widget
[page
248]

4.3 Repository
The SAP HANA repository is the design-time storage system for development objects and is built into SAP HANA.
The repository is the source control for all your development work on SAP HANA. You can add objects to the
repository, update the objects, publish the objects, and compile these design-time objects into runtime objects.
SAP HANA Developer Guide
SAP HANA as a Development Platform
P UBL I C
©
2012 SAP AG. All rights reserved.
23
The repository supports the following:
 Version Control
 Sharing of objects between multiple developers
 Transport
The repository manages all development objects. You can browse the repository for a specific system with the
SAP HANA Repositories view.
Packages
Within the repository, development objects are managed as files within packages. Packages enable you to:
 Create namespaces, so you can uniquely identify development objects.
 Group objects that logically belong together.
 Provide containers for your objects so you can easily insert relevant objects into delivery units and transport
them.
 Assign permissions at the package level.
You might create a top-level package for your company, and then a subpackage for each project, and then
subpackages for parts of your project, for example, a subpackage for your HTML files, another for server-side
JavaScript files, and so forth.
Workspaces
When working with development objects, you need to retrieve them from the repository, work on them on your
workstation, and then return them to the repository. To make this simpler, the SAP HANA studio enables you to
create a repository workspace, which establishes a link between two locations:

 The repository of the SAP HANA system where you wish to maintain the development object files of your
projects (in the form of a package hierarchy).
 A directory/folder on your workstation where you checkout these project files while you are working on them.
Working with Objects
When creating development objects, the following is the workflow:
1. Create a project.
24
P UBL I C
©
2012 SAP AG. All rights reserved.
SAP HANA Developer Guide
SAP HANA as a Development Platform
2. Share the project to associate it with a workspace, and thus a specific SAP HANA system. Shared projects,
once they are activated, are available for import by other members of the application-development team.
3. Create a new object file within the project, and save it to your workstation. Depending on the extension of the
file you create, you may use a dedicated editor for that type of object, for example, a JavaScript editor
for .xsjs files.
4.
Commit the file.
Committing the file saves it in the repository, but the object is inactive and cannot be run, and only you can
see it.
5. Activate the file.
Activating a file does the following:
 Publishes the file so others can see it.
 Adds the previously active version of the file to the history. The repository maintains a history of changes
to the file.
 Validates the file and compiles it or exposes it as a runtime object.
The design-time object is now active.
Related Links
Setting Up Your Application

[page 36]
In SAP HANA Extended Application Services (SAP HANA XS), the design-time artifacts that make up your
application are stored in the repository like files in a file system. You first choose a root folder for your
application-development activities, and within this folder you create additional subfolders to organize the
applications and the application content according to your own requirements.
4.4 SAP HANA Studio
The SAP HANA studio is an Eclipse-based development and administration tool for working with SAP HANA,
including creating projects, creating development objects, and deploying them to SAP HANA. As a developer, you
may want to also perform some administrative tasks, such as configuring and monitoring the system.
There are several key Eclipse perspectives that you will use while developing:
 Modeler: Used for creating various types of views and analytical privileges.
 SAP HANA Development: Used for programming applications, that is, creating development objects that
access or update the data models, such as server-side JavaScript or HTML files.
 Debug: Used to debug code, such as server-side JavaScript or SQLScript.
 Administration: Used to monitor the system and change settings.
To open a perspective, go to
Window Open Perspective , or select on the toolbar.
SAP HANA Developer Guide
SAP HANA as a Development Platform
P UBL I C
©
2012 SAP AG. All rights reserved.
25

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×