• No results found

Ha400 en Col08 Fv Part a4

N/A
N/A
Protected

Academic year: 2021

Share "Ha400 en Col08 Fv Part a4"

Copied!
453
0
0

Loading.... (view fulltext now)

Full text

(1)

HA400

ABAP Programming for SAP HANA

SAP HANA Date Training Center Instructors Education Website

Participant Handbook

Course Version: 08

Course Duration: 3 Day(s) Material Number: 50124861

(2)

No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice.

Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.

Trademarks

Adobe, the Adobe logo, Acrobat, PostScript, and Reader are trademarks or registered trademarks of Adobe Systems Incorporated in the United States and other countries.

Apple, App Store, FaceTime, iBooks, iPad, iPhone, iPhoto, iPod, iTunes, Multi-Touch, Objective-C, Retina, Safari, Siri, and Xcode are trademarks or registered trademarks of Apple Inc.

Bluetooth is a registered trademark of Bluetooth SIG Inc.

Citrix, ICA, Program Neighborhood, MetaFrame now XenApp, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems Inc.

Computop is a registered trademark of Computop Wirtschaftsinformatik GmbH.

Edgar Online is a registered trademark of EDGAR Online Inc., an R.R. Donnelley & Sons Company. Facebook, the Facebook and F logo, FB, Face, Poke, Wall, and 32665 are trademarks of Facebook. Google App Engine, Google Apps, Google Checkout, Google Data API, Google Maps, Google Mobile Ads, Google Mobile Updater, Google Mobile, Google Store, Google Sync, Google Updater, Google Voice, Google Mail, Gmail, YouTube, Dalvik, and Android are trademarks or registered trademarks of Google Inc.

HP is a registered trademark of the Hewlett-Packard Development Company L.P.

HTML, XML, XHTML, and W3C are trademarks, registered trademarks, or claimed as generic terms by the Massachusetts Institute of Technology (MIT), European Research Consortium for Informatics and Mathematics (ERCIM), or Keio University.

IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, z10, z/VM, z/OS, OS/390, zEnterprise, PowerVM, Power Architecture, Power Systems, POWER7, POWER6+, POWER6, POWER, PowerHA, pureScale, PowerPC, BladeCenter, System Storage, Storwize, XIV, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, AIX, Intelligent Miner, WebSphere, Tivoli, Informix, and Smarter Planet are trademarks or registered trademarks of IBM Corporation.

Microsoft, Windows, Excel, Outlook, PowerPoint, Silverlight, and Visual Studio are registered trademarks of Microsoft Corporation.

INTERMEC is a registered trademark of Intermec Technologies Corporation. IOS is a registered trademark of Cisco Systems Inc.

(3)

RIM, BlackBerry, BBM, BlackBerry Curve, BlackBerry Bold, BlackBerry Pearl, BlackBerry Torch, BlackBerry Storm, BlackBerry Storm2, BlackBerry PlayBook, and BlackBerry AppWorld are trademarks or registered trademarks of Research in Motion Limited.

SAVO is a registered trademark of The Savo Group Ltd. The Skype name is a trademark of Skype or related entities.

Twitter and Tweet are trademarks or registered trademarks of Twitter.

UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Wi-Fi is a registered trademark of Wi-Fi Alliance.

SAP, R/3, ABAP, BAPI, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP BusinessObjects Explorer, StreamWork, SAP HANA, the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, Sybase, Adaptive Server, Adaptive Server Enterprise, iAnywhere, Sybase 365, SQL Anywhere, Crossgate, B2B 360° and B2B 360° Services, m@gic EDDY, Ariba, the Ariba logo, Quadrem, b-process, Ariba Discovery, SuccessFactors, Execution is the Difference, BizX Mobile Touchbase, It's time to love work again, SuccessFactors Jam and BadAss SaaS, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany or an SAP affiliate company. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.

Disclaimer

These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies (“SAP Group”) for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.

(4)
(5)

This handbook is intended to complement the instructor-led presentation of this course, and serve as a source of reference. It is not suitable for self-study.

Typographic Conventions

American English is the standard used in this handbook. The following typographic conventions are also used.

Type Style Description

Example text Words or characters that appear on the screen. These include field names, screen titles, pushbuttons as well as menu names, paths, and options.

Also used for cross-references to other documentation both internal and external.

Example text Emphasized words or phrases in body text, titles of graphics, and tables

EXAMPLE TEXT Names of elements in the system. These include report names, program names, transaction codes, table names, and individual key words of a programming language, when surrounded by body text, for example SELECT and INCLUDE.

Example text Screen output. This includes file and directory names and their paths, messages, names of variables and parameters, and passages of the source text of a program.

Example text Exact user entry. These are words and characters that you enter in the system exactly as they appear in the documentation.

<Example text> Variable user entry. Pointed brackets indicate that you replace these words and characters with appropriate entries.

(6)

Icons in Body Text

The following icons are used in this handbook.

Icon Meaning

For more information, tips, or background

Note or further explanation of previous point Exception or caution

Procedures

Indicates that the item is displayed in the instructor's presentation.

(7)

Course Overview ... ix

Course Goals ... ix

Course Objectives ... ix

Unit 1: Introduction... 1

SAP HANA Basics and Technical Concepts ...3

Introduction to SAP HANA Studio ... 22

Introduction to ABAP Development Tools (ADT) ... 32

Introduction to the EPM Sample Application ... 46

Unit 2: Taking ABAP to SAP HANA ... 53

SAP HANA as Secondary Database – Access via Open SQL . 55 Preparing for SAP HANA ... 69

Guided Performance Analysis... 90

Performance Rules and Guidelines for SAP HANA ... 114

Unit 3: Code-to-Data with SAP HANA as Secondary Database ... 121

Classical Open SQL and Its Limitations ...123

ABAP Database Connectivity (ADBC) ...129

Native SQL Syntax...133

Working with Views in SAP HANA Studio ...154

Consuming SAP HANA Views via Native SQL ...163

Working With Database Procedures in SAP HANA Studio...178

Calling SAP HANA Procedures in ABAP ...184

Unit 4: Optimizing ABAP On Primary Database SAP HANA .. 199

New Open SQL ...200

Core Data Services in ABAP ...219

Associations in Core Data Services ...242

Unit 5: Using ABAP-managed Database Procedures ... 253

ABAP-Managed Database Procedures ...254

Debugging ABAP-managed Database Procedures ...271

Unit 6: SAP HANA Proxy Objects ... 281

Accessing SAP HANA Views via ABAP Dictionary External Views...283

(8)

Calling SAP HANA Procedures via ABAP Database Procedure

Proxies...308

Unit 7: Advanced Topics ... 323

Using SAP HANA Full Text Search ...324

ABAP List Viewer (ALV) with Integrated Access to SAP HANA 351 Unit 8: Case Study: Optimize a Report on Flight Customer Revenue ... 373

Creating an Analytic View...374

Unit 9: Appendix ... 403

(9)

Target Audience

This course is intended for the following audiences:

• Developers and development consultants who need to write or review performance-optimized ABAP code for SAP HANA.

Course Prerequisites

Required Knowledge • HA100 HANA Overview

• BC400 ABAP Workbench Fundamentals • BC401 ABAP Objects

• Experience in ABAP Programing ( procedural and object oriented) • Open SQL details (joins, views, aggregations)

Recommended Knowledge • HA150 SQL Basics for SAP HANA

Course Goals

This course will prepare you to:

• Develop and optimize ABAP applications that access data stored in the SAP HANA Database

Course Objectives

After completing this course, you will be able to: • Understand the technical concepts of SAP HANA

• Understand how to optimize classic ABAP for SAP HANA

• Describe the use of analysis tools for performance optimization (Runtime Analysis, Code Inspector, SQL Trace, SQL Performance Tuning Worklist) • Understand the SQL performance rules of ABAP for SAP HANA

• Access SAP HANA from ABAP using native SQL and ADBC (ABAP Database Connectivity)

• Use enhanced Open SQL

(10)

• Call SAP HANA stored procedures in ABAP and embed stored procedures in ABAP

• Consume SAP HANA views in ABAP • Create a simple SAP HANA view

(11)

Unit 1

Introduction

Unit Overview

This unit is designed to teach the following topics: • SAP HANA basics

• SAP HANA technical concepts • Introduction to SAP HANA Studio • Introduction to ABAP Development Tools

Unit Objectives

After completing this unit, you will be able to:

• Describe SAP HANA goals, technical innovations and challenges • Understand the fundamental technical concepts of SAP HANA

• Explain the SAP HANA and ABAP evolution, architecture, and direction • Determine if HANA’s row store or column store is used for an ABAP

transparent table, and which indices are used on HANA • Explain the central functions of HANA Studio

• Switch between different perspectives in the SAP HANA Studio • Set up a connection to a SAP HANA database

• Understand schemata and tables in SAP HANA Studio • Analyze the definition of tables in SAP HANA Studio • Use the ABAP Development Tools in Eclipse

• Describe the Enterprise Procurement Model business example • Describe the Open Item Analytics sample applications and which

computations it involves

Unit Contents

Lesson: SAP HANA Basics and Technical Concepts ...3

Exercise 1: Log on to ABAP Systems and Create Packages ... 17

Lesson: Introduction to SAP HANA Studio ... 22

(12)

Lesson: Introduction to ABAP Development Tools (ADT) ... 32 Exercise 3: Create a Project in ABAP Development Tools ... 41 Lesson: Introduction to the EPM Sample Application... 46

(13)

Lesson: SAP HANA Basics and Technical Concepts

Lesson Overview

Lesson Objectives

After completing this lesson, you will be able to:

• Describe SAP HANA goals, technical innovations and challenges • Understand the fundamental technical concepts of SAP HANA

• Explain the SAP HANA and ABAP evolution, architecture, and direction • Determine if HANA’s row store or column store is used for an ABAP

transparent table, and which indices are used on HANA

Business Example

Your company has recognized SAP HANA as an important strategic topic and has asked you to refresh your ABAP skills, paying particular attention to those required to develop or review code that leverages the strengths of SAP HANA.

SAP HANA Goals

Figure 1: Today's Technology Requires Tradeoff Decisions

Developing applications using technology that pre-dates SAP HANA typically required making several trade-off decisions.

The figure shows the five dimensions of requirements that are typical for business applications. These dimensions have been conflicting so far.

For example, you had to make trade-off decisions between providing a high-speed application and developing an application that doesn’t require preparing the data in a special way first, for example by calculating aggregations beforehand and by

(14)

storing the results in addition to the base data. Another example is that it was not possible to develop an application which is both real-time and able to analyze a large amount of data, maybe even unstructured data, at the same time.

Figure 2: SAP HANA: Delivers Across 5 Dimensions

SAP HANA tries to deliver across all these 5 dimensions, so that you no longer have to make so many trade-off decisions. In other words, the ambition is to enable developing applications which combine Online Transaction Processing and Online Analytical Processing usage patterns. This leads to certain goals HANA has to meet.

Figure 3: SAP HANA Goals

SAP HANA has the following goals:

Enable New Applications and Optimize Existing Applications

(15)

High Performance and Scalability

SAP HANA is designed to make full use of multi-core CPUs by

parallelization of execution. It can be distributed across multiple servers

to achieve good scalability in terms of both data volume and concurrent requests.

Hybrid Data Management System – Combining different paradigms in one system

SAP HANA architecture integrates different in-memory storages

(column-based, row-based and object-based), traditional disk-based tables, text analysis and search, and built-in support for planning. Combining all these capabilities in a single product not only improves performance but reduces overall complexity and cost.

Compatibility and Standard DBMS Features

An important goal is the possibility to use the SAP HANA database system as a replacement for any standard relational database management system. The SAP HANA database system is a full relational database management

system with SQL interface, transactional isolation and recovery (ACID

properties) and high availability. SAP applications that use Open SQL should run on SAP HANA without changes.

Support For Text Analysis, Indexing and Search

An important goal of SAP HANA is to provide powerful analysis, text

indexing and search capabilities that support a state-of-the-art search

experience. This includes full text search with advanced features such as free style search (without knowing the name of attributes in the database),

linguistic search and fault-tolerant fuzzy search. Cloud Support and Application Isolation

In cloud deployments it is required to share a system – including physical servers and installed software – between multiple customers. SAP HANA will support this in the future with the planned ability to host multiple isolated databases within a single SAP HANA system. The databases inside one system will have their own data, metadata and users, but will share the same hardware, the same SAP HANA software installation, and the system administration. This feature helps to support cloud scenarios – but it can also be used in an on-premise deployment, for example for running multiple unrelated applications in one SAP HANA system with effective isolation and resource management.

Support for Temporal Tables

SAP applications that use Open SQL should run on SAP HANA without changes. In temporal tables update operations do not modify the existing records. Instead new versions of the data records are inserted. Applications may use temporal tables for example for time-based reporting and analysis or for versioning and change recording purposes.

(16)

Executing Application Logic inside the Data Layer

To benefit from the parallelization and optimization capabilities of SAP HANA, applications must execute data intensive operations on the database level. Pushing calculations to the database layer can also significantly reduce the amount of data that needs to be transferred between database and application server. SAP HANA allows application developers to define application-specific functions that are executed inside the database layer.

SAP HANA Application Architectures

SAP HANA can be used in different architectural scenarios, which in turn provide the technological base for the different application areas. From an ABAP programmer's point of view there are two groups of scenarios: Those where SAP HANA functions as database for an Application Server ABAP and scenarios based on a standalone SAP HANA Server. Naturally, the non-ABAP scenarios are just mentioned here and are not in the focus of this course.

Types of SAP HANA-Based Applications

Figure 4: Architectural Scenarios

SAP HANA can be used in different architectural scenarios, which in turn provide the technological base for the different application areas.

From an ABAP programmer’s point of view there are two groups of scenarios: Those where SAP HANA functions as database for an Application Server ABAP and scenarios based on a standalone SAP HANA Server.

Naturally, the non-ABAP scenarios are just mentioned here and are not in the focus of this course:

(17)

A second type of HANA-based applications are newly-built, native applications developed using SAP HANA Extended Application Services.

Figure 5: SAP HANA as Database for ABAP Applications

Primary concern of this course is to learn how to optimize ABAP applications directly running on SAP HANA, that is application using SAP HANA as the primary database underneath the ABAP stack. A typical example for this kind of application is SAP CRM powered by SAP HANA, or the Business Suite powered by SAP HANA.

The course also covers the right-hand type of applications: using SAP HANA to accelerate ABAP applications by putting a separate HANA server besides the ABAP stack, replicating some the ABAP system’s data into HANA, and calling HANA remotely from ABAP to speed up selected reports or transactions.

SAP HANA Innovations and Challenges

(18)

Dramatically improved hardware economics and technology innovations in software made it possible for SAP to deliver on its vision of the Real-Time Enterprise with in-memory business applications. Understanding them is important to understand SAP HANA’s performance characteristics.

In-Memory Computing and the Shift of Performance Bottlenecks Historically, database systems were designed to perform well on computer systems with limited RAM. This had the effect that slow disk I/O was the main bottleneck in data throughput. Consequently the architecture of those systems was designed with a focus on optimizing disk access, e. g. by minimizing the number of disk blocks (or pages) to be read into main memory when processing a query.In addition, CPUs had a single core, network was far slower etc.

Figure 7: Shift of Performance Bottlenecks

Computer architecture has changed in recent years. Now multi-core CPUs (multiple CPUs on one chip or in one package) are standard, with fast communication between processor cores enabling parallel processing. Main memory is no longer a limited resource, modern servers can have 2TB of system memory and this allows complete databases to be held in RAM.

Currently server processors have up to 64 cores, and 128 cores will soon be available. With the increasing number of cores, CPUs are able to process increased data per time interval.

(19)

Figure 8: New Bottlenecks Become Important – How To Avoid Them?

To fully get the most out of current hardware, the new bottlenecks have to be avoided by addressing two challenges:

• Avoid CPU cache misses and expensive data transfer from main memory into the CPU – optimize loading the data into the CPU.

• Avoid idling CPU cores – make use of parallelism by using all the cores of a CPU, and several CPUs.

Column Store versus Row Store

Figure 9: Row Store

By accessing data in column-store order, you benefit immensely from simplified table-scan and data pre-caching. This can make all the difference in performance.

(20)

Figure 10: Column Store

Data Compression

Figure 11: Columnar Dictionary Compression

SAP HANA uses different, efficient compression methods such as dictionary encoding, run-length encoding and more.

Reduces the amount of memory required.

Speeds up operations on columns because the columns can be loaded into the

CPU caches faster and with fewer loading cycles.

Speeds up operations on columns because many comparisons become integer

(21)

Partitioning and Parallel Processing

Figure 12: Parallel Processing

On SAP HANA and with column storage, data is only partially blocked. This makes parallel processing possible. Even the same column can be split up and processed by different cores at the same time.

Figure 13: Using Partitioning To Further Leverage Parallelism

Making use of parallelism can be taken a step further by creating different partitions of the data to be stored and processed on different blades. This allows managing and processing huge amounts of data.

(22)

ABAP Programming for SAP HANA: Evolution and

Opportunities

Figure 14: SAP HANA Evolution

What's in it for ABAP Programmers?

The new capabilities of SAP HANA offer a huge variety of opportunities for ABAP Developers:

(23)

Accelerate

By optimizing the coding of long running background jobs for SAP HANA, their runtime can be reduced. More jobs can be executed in the same time window, particularly costly tasks are possible in one go rather than splitting them up.

Extend

In the past, some reports had to be executed in background simply because their runtime was too long for dialog processing. Consequently, users worked on snapshots or pre-aggregated data sets. By optimizing these reports with SAP HANA, they can be offered as online-reports again, displaying real-time data with full drill-down capability.

Innovation

Finally, with SAP HANA's analysis and calculation capabilities, ABAP developers can design completely new applications that would not have been possible in the past.

The arrival of in-memory technology on the database layer also requires a change in the way we design and implement applications:

Figure 16: New Programming Approach

The basic approach of classic ABAP programming was: Keep load from the database

Get all the data you need on the application server and do your processing in ABAP

(24)

But in order to benefit the most from SAP HANA's capabilities it is better to do expensive calculations and aggregations on the database itself rather than transferring huge amounts of data onto the ABAP application server. This is a fundamental change to the ABAP programming paradigm. Now it becomes “logic to data“ rather than” data to logic”.

Figure 17: Highlights of SAP NetWeaver AS ABAP 7.4 – Overview

ABAP 7.4 provides support for optimizing ABAP applications running on

SAP HANA.

There are transparent optimizations:

These are optimizations you don’t see as an application developer, but which you benefit from because they happen under the hood. An example is the SELECT… FOR ALL ENTRIES… statement in OpenSQL, the implementation of which has been improved.

The ABAP language and the OpenSQL language have been extended. For example, OpenSQL now supports more complicated Joins and sub-queries, and there are ways to integrate SAP HANA stored procedures, in other words SQL Script, in ABAP code.

Consumption of SAP HANA artifacts has been simplified. For example, you can access SAP HANA columns views through the ABAP Dictionary, that is using OpenSQL.

In addition, performance analysis tools have been improved, for example static code checks and the runtime analysis. The ABAP Profiler perspective in the ABAP Development Tools in Eclipse has been enhanced as well.

(25)

In addition, the ABAP platform team provides guidelines for optimizing ABAP

code running on HANA.

Figure 18: ABAP Dictionary Extensions in ABAP 7.4

An example for an ABAP Dictionary extension in ABAP 7.4 is the capability to control which store a table of the ABAP system should live in.

A new tab has been added to the Maintain Technical Settings form for database tables. The new tab is called DB-Specific Properties, and allows to switch between three storage types when running on a SAP HANA database:

Storage type Column Store, which creates the database table in SAP HANA’s column store, or moves it there.

Storage type Row Store, which creates the database table in SAP HANA’s row store or moves it there.

• In principle, this setting can be changed after the table has been created, and the table will be moved into the other store. Note, however, that this may involve re-organizing table contents, should such content exist already. So use this with caution.

(26)
(27)

Exercise 1: Log on to ABAP Systems and

Create Packages

Exercise Objectives

After completing this exercise, you will be able to:

• Log on to SAP NetWeaver Application Server ABAP and create a development package

Business Example

Your company has recognized SAP HANA as an important strategic topic and has asked you to refresh your ABAP skills, paying particular attention to those required to develop or review code that leverages the strengths of SAP HANA.

Task 1: Log on to Application Server ABAP with SAP

HANA as primary database

In SAP GUI, log on to the Application Server ABAP that uses SAP HANA as a primary database. Use the System ID, user and password provided by your instructor. Create development package ZHA400_##, where ## stands for your group ID.

1. Start SAPlogon and log on to the system labelled NW740 on HANA. 2. Open system status and check the system's release and database. 3. Start transaction SE80 and create the package. Assign the package to

application component “CA” and software component “HOME”. Use the workbench request already created by your instructor (press button Own

Requests to find and use this request).

4. Start transaction SE11 and open the definition of table “BUT000”. Which of SAP HANA's table stores is used for table “BUT000”? In other words: what is the table's storage type?

5. Inspect the secondary database indices defined for table “BUT000”. Which of the non-unique indexes are generated when the ABAP system is deployed on an SAP HANA database, and which non-unique indexes are not created on SAP HANA?

6. What is the main differences between the indexes created on SAP HANA, and those created on other DBMSs?

(28)

Task 2: Log on to other Application Server ABAP with

Sybase as primary database

In SAP GUI, log on to the Application Server ABAP that does not have SAP HANA as a primary database. Use the System ID, user and password provided by your instructor. Create development package ZHA400_##, where ## stands for your group ID.

1. Start SAPlogon and log on to the system labelled ZME on Sybase. 2. Open system status and check the system's release and database. 3. Start transaction SE80 and create the package. Assign the package to

application component “CA” and software component “HOME”. Use the workbench request already created by your instructor (press button Own

(29)

Solution 1: Log on to ABAP Systems and

Create Packages

Task 1: Log on to Application Server ABAP with SAP

HANA as primary database

In SAP GUI, log on to the Application Server ABAP that uses SAP HANA as a primary database. Use the System ID, user and password provided by your instructor. Create development package ZHA400_##, where ## stands for your group ID.

1. Start SAPlogon and log on to the system labelled NW740 on HANA. a) Perform this step as you have (hopefully) done before.

2. Open system status and check the system's release and database. a) From the main menu bar, open System → Status....

b) In frame SAP System data, press button Component Information to see the installed components and their versions.

c) In frame Database data check the content of field Database System. 3. Start transaction SE80 and create the package. Assign the package to

application component “CA” and software component “HOME”. Use the workbench request already created by your instructor (press button Own

Requests to find and use this request).

a) Perform this step as you have (hopefully) done before.

4. Start transaction SE11 and open the definition of table “BUT000”. Which of SAP HANA's table stores is used for table “BUT000”? In other words: what is the table's storage type?

a) Open Technical Settings, tab DB-Specific Properties. Storage Type is Column Store

5. Inspect the secondary database indices defined for table “BUT000”. Which of the non-unique indexes are generated when the ABAP system is deployed on an SAP HANA database, and which non-unique indexes are not created on SAP HANA?

a) Return to Display Table, then open Indexes

b) 15 secondary, non-unique indexes are defined for table “BUT000” in the ABAP Dictionary. Of these, the 7 indexes “H6Z, H7D, H7M, HED, HHT, HLT” and “HOL” are only created if the ABAP system runs on SAP HANA. The 8 indexes “ADR, EXT, FRD, GUI, NAM, PER, SRT” and “TOD” are not created if the ABAP system runs on SAP HANA, but only on all other supported DBMSs.

(30)

6. What is the main differences between the indexes created on SAP HANA, and those created on other DBMSs?

a) The indexes created on SAP HANA are all indexes on a single column only. I.e. they don't contain the CLIENT column, and index “H7M” is on the “BU_SORT2” column only, compared to index “SRT” which comprises columns “CLIENT, BU_SORT1” and “BU_SORT2”.

Task 2: Log on to other Application Server ABAP with

Sybase as primary database

In SAP GUI, log on to the Application Server ABAP that does not have SAP HANA as a primary database. Use the System ID, user and password provided by your instructor. Create development package ZHA400_##, where ## stands for your group ID.

1. Start SAPlogon and log on to the system labelled ZME on Sybase. a) Perform this step as before.

2. Open system status and check the system's release and database. a) Perform this step as before.

3. Start transaction SE80 and create the package. Assign the package to application component “CA” and software component “HOME”. Use the workbench request already created by your instructor (press button Own

Requests to find and use this request).

(31)

Lesson Summary

You should now be able to:

• Describe SAP HANA goals, technical innovations and challenges • Understand the fundamental technical concepts of SAP HANA

• Explain the SAP HANA and ABAP evolution, architecture, and direction • Determine if HANA’s row store or column store is used for an ABAP

(32)

Lesson: Introduction to SAP HANA Studio

Lesson Overview

Lesson Objectives

After completing this lesson, you will be able to: • Explain the central functions of HANA Studio

• Switch between different perspectives in the SAP HANA Studio • Set up a connection to a SAP HANA database

• Understand schemata and tables in SAP HANA Studio • Analyze the definition of tables in SAP HANA Studio

Business Example

Your company has recognized SAP HANA as an important strategic topic and has asked you to refresh your ABAP skills, paying particular attention to those required to develop or review code that leverages the strengths of SAP HANA.

SAP HANA Studio – An Eclipse Based Tool

(33)

The tool to perform such tasks on the SAP HANA layer is the SAP HANA studio. SAP HANA studio is an Eclipse-based integrated development environment, and also provides tools to administer, monitor and configure SAP HANA systems.

These tools are based on existing Eclipse frameworks.

SAP chose Eclipse as the platform for an SAP HANA IDE because Eclipse is SAP’s strategic platform for integrated design-time and development tools in general. The open Eclipse platform offers first-class user experience, powerful platform capabilities, and a broad and vivid ecosystem that regularly contributes enhancements and extensions.

What is Eclipse? Eclipse is a platform that has been designed for building integrated Web and application development tools. The platform does not provide a great deal of end-user functionality by itself. The value of the platform is what it encourages: rapid development of integrated features based on a plugin model. SAP plays an active role in the Eclipse Foundation as one of its strategic members. Many of the SAP design-time, development, and administration tools already make use of the Eclipse platform. These include SAP NetWeaver Visual Composer, the Sybase Unwired Platform and the SAP HANA studio.

These include SAP NetWeaver Visual Composer, the Sybase Unwired Platform and the SAP HANA studio.

As a result of SAP’s strategy, SAP also provides an Eclipse-based development environment for ABAP called ABAP Development Tools for Eclipse (ADT). This makes it possible to combine both development environments in a single, common IDE for both ABAP and SAP HANA development.

(34)

Like most Eclipse-based development environments, SAP HANA studio provides

several Perspectives within the Eclipse workbench.

Each perspective is tailored for particular groups of tasks and is a pre-configured set of panes called views. Examples for perspectives are:

• Administration console – to administer, monitor and configure SAP HANA systems

• Modeler – to develop information models and database procedures • SAP HANA Development – to develop native SAP HANA-based

applications using SAP HANA Extended Application Services Examples for views are:

• Systems – visible in most SAP HANA perspectives and showing the list of SAP HANA systems the IDE is connected to

• Properties – showing properties of the currently selected object, e.g. the properties of a configured SAP HANA system

• Job Log – showing the list of recent jobs performed, e.g. imports of development objects, activations etc.

Details of HANA Studio

Figure 21: Most Relevant Perspective For ABAP Developers: Modeler

(35)

The Modeler is the perspective most relevant for ABAP developers. It provides access to the views and database procedures that you can consume in the ABAP environment. You can open it using the menu item Window → Open Perspective or the Open Perspective button in the toolbar.

A central part of this perspective is the Systems view on the left-hand side. This view contains a list of systems. Each system represents a logon to an SAP HANA system with a particular user. Systems can be grouped in folders to structure the list.

Figure 22: System View

Each system shows a hierarchy of objects visible to this user.

The catalog consists of one or several schemas, each containing a set of database objects, like database tables and database views.

The content contains models, i.e. specific objects that allow an optimized access to the database tables. Part of these models are SAP HANA views and database

procedures. SAP HANA views and database procedures are arranged in content packages, which are similar to ABAP packages, in that they group objects that

(36)

Systems – Access to SAP HANA Server

Figure 23: Connecting to an SAP HANA Database

To connect to an SAP HANA system and see the corresponding catalog, content etc., use the Systems view, context menu item Add System ...

To add a system, you need:

• Host Name on which the SAP HANA system is installed. Note that this typically is different from the host of the ABAP system

• Instance Number of the SAP HANA system.Again note that this typically is different from the instance number of the ABAP system

• Description

• Database user – also different from your ABAP user • Password for the database user

(37)

The Catalog – Tables

Figure 24: Tables definitions

Once connected, you can open the database catalog and look, for example, at the definition of tables on the SAP HANA layer. The table editor also allows exporting the SQL statement used to create the database table.

SAP HANA Content – Packages and Models

Figure 25: SAP HANA Content – Packages, Models, Delivery Units

To develop SAP HANA information models, special types of views and database procedures for optimized read access, you should create your own Content packages.

(38)

Transport of SAP HANA Content: Delivery Units

To transport of SAP HANA content, packages are assigned to delivery units. Each package may be assigned to one delivery unit only.

Navigate to the administration view for delivery units from the Quick Launch view. Each delivery unit must have a unique name. When creating a new delivery unit, a vendor name is automatically derived from the system settings and linked with this delivery unit. SAP’s vendor name is “sap.com”.

You can assign whole hierarchies of packages to the same delivery unit from within the administration of delivery units.

Hint: Alternatively, a delivery unit can be entered in the definition of a

(39)

Exercise 2: Log on to SAP HANA Studio

Exercise Objectives

After completing this exercise, you will be able to:

• Open the SAP HANA Studio and connect to the SAP HANA Server • Create a content package in SAP HANA

• Create a delivery unit and assign a package to it

Business Example

Your company has recognized SAP HANA as an important strategic topic and has asked you to refresh your ABAP skills, paying particular attention to those required to develop or review code that leverages the strengths of SAP HANA.

Task 1: Log on to SAP HANA

Open the SAP HANA Studio and establish a connection to the SAP HANA Server provided by your instructor.

Create content package zha400-##, where ## stands for your group ID. Create delivery unit ZHA400_## and assign your package to it.

1. Open SAP HANA Studio.

2. Add a new system. Use the server name, user ID and password provided by your instructor.

Task 2: Create a Content Package and Delivery Unit

Create content package zha400-##, where ## stands for your group ID. Create delivery unit ZHA400_## and assign your package to it.

1. Create the content package. 2. Create the delivery unit.

(40)

Solution 2: Log on to SAP HANA Studio

Task 1: Log on to SAP HANA

Open the SAP HANA Studio and establish a connection to the SAP HANA Server provided by your instructor.

Create content package zha400-##, where ## stands for your group ID. Create delivery unit ZHA400_## and assign your package to it.

1. Open SAP HANA Studio.

a) Choose Start → All Programs → SAP HANA → SAP HANA Studio from the Windows Start Menu

2. Add a new system. Use the server name, user ID and password provided by your instructor.

a) Make sure you are in the Modeler perspective. If not, change perspective using the buttons in the upper right-hand corner.

b) Right-click anywhere in the Systems window on the left and choose

Add System....

c) Enter host name and instance number provided by your instructor and a description, then press button Next >.

d) Enter user ID and password provided by your instructor, then choose

Finish.

Task 2: Create a Content Package and Delivery Unit

Create content package zha400-##, where ## stands for your group ID. Create delivery unit ZHA400_## and assign your package to it.

1. Create the content package.

a) In the Systems window, open node Content. Right click on this node and choose New → Package....

b) Enter the package name and a description, then press button OK. 2. Create the delivery unit.

a) Open view Quick Launch. b) Click on link Delivery Units.

(41)

Lesson Summary

You should now be able to:

• Explain the central functions of HANA Studio

• Switch between different perspectives in the SAP HANA Studio • Set up a connection to a SAP HANA database

• Understand schemata and tables in SAP HANA Studio • Analyze the definition of tables in SAP HANA Studio

(42)

Lesson: Introduction to ABAP Development Tools (ADT)

Lesson Overview

As an open framework, Eclipse can host a whole range of development tools. As well as the SAP HANA Studio environment, SAP also provides a suite of tools known as the ABAP Development Tools. These enable you to develop ABAP resources using Eclipse as a frontend development environment.

Lesson Objectives

After completing this lesson, you will be able to: • Use the ABAP Development Tools in Eclipse

Business Example

Your company has recognized SAP HANA as an important strategic topic and has asked you to refresh your ABAP skills, paying particular attention to those required to develop or review code that leverages the strengths of SAP HANA.

Using ABAP Development Tools

(43)

ABAP Development Tools provides the following:

• A brand new ABAP development experience on top of the Eclipse platform • An open platform for developing new ABAP-related tools

• A set of open, language- and platform-independent APIs that developers can use to build new custom tools for the ABAP environment

Benefits of Eclipse

With ABAP Development Tools in Eclipse you can capitalize on the usability, speed and flexibility of Eclipse while also benefitting from proven ABAP Workbench features. It’s the best of both worlds.

ADT improves developer productivity by offering better refactoring functionality, code completion, auto-insertion, and code templates. It also includes an invaluable Quick Fix feature and is highly navigable.

ADT allows you to connect to multiple ABAP systems and provides session failover, reducing the impact of lost connections. It also enables cross-platform development by integrating ABAP and non-ABAP development tools in a single powerful IDE.

Note: In addition, ADT is tightly integrated with HANA Studio, SAP

UI5 tools and JAVA.

The architecture of ABAP Development Tools for SAP NetWeaver is an architecture designed for ease of use and flexibility. It is designed so that developers use a single Eclipse client, installed locally, that connects to several ABAP back-end systems of different releases using an RFC/REST-based protocol. This allows developers to control all activities in a central location and helps avoid time-consuming context switches. The client provides a set of standard Eclipse development tools, such as the project explorer for system browsing and search views.

When you use ADT, you log onto an SAP backend system and work directly with its Repository objects. In this sense, the development process is exactly the same as when you use the ABAP Workbench - there is no check-out and check-in of the objects. Each connection that you make is represented in Eclipse by an ABAP

Project.

An ABAP project serves as container for the development objects that are stored in particular ABAP backend system containing

the logon parameters for a particular system logon like: • System

• Client

(44)

You must be logged onto the system in order to edit a particular resource. Within the project, you can access any development object in the Repository. However, to make it easier to manage the objects you use regularly, you can set up favorite packages for each project.

Within the project, there is a navigation view similar to the one in the ABAP Workbench. The source library contains not only programs, but also classes, interfaces and function modules, which you edit in a source code editor rather than in the traditional form-based mode.

Note: You can create multiple ABAP projects in Eclipse, each related

to a different system.

Figure 27: ABAP Development Tools – Editors

There are two kinds of editors in ADT – those for which there is a “native” Eclipse implementation and others that appear in-place in the SAP GUI. The figure above shows each kind – the ABAP Editor as an example of an Eclipse editor and the ABAP Dictionary showing how the classic SAP GUI visualization appears within the Eclipse environment.

Generally speaking, there is no requirement to use ADT for ABAP Development, and each developer is free to choose whether to use ADT or the classic ABAP Workbench. The functions and features of Eclipse in general and ADT in

(45)

Some new functions, however, are only provided within ADT and do not have an equivalent function in the ABAP Workbench. Serveral of these pertain to ABAP development for SAP HANA.

Working with ADT

Figure 28: ABAP Project

(46)

Figure 30: ADT Quick Reference Card

ADT provides a large number of keyboard shortcuts that can make you more productive. You can download a quick reference card with the most important shortcuts from SCN page http://scn.sap.com/commu-nity/abap/eclipse/blog/2012/07/02/adt-quick-reference-card.

Examples for keyboard shortcuts ABAP developers new to ADT often don‘t find quickly are:

• Shift+F1 to format the source code, i.e. use the “pretty printer”

• Ctrl+< and Ctrl+> to turn a line of code into a comment or to remove a comment, or Ctrl+7 to toggle between commenting/de-commenting a line • F3 to navigate to the definition of the currently selected object (forward

navigation).Pressing the Ctrl key while positioning the mouse over an object, e.g. a class or method name, adds a link and allows to navigate to the definition or implementation of the object.

(47)

Figure 31: Editing Source Code

The source code editor in ADT provides many helpful features, for example: • Code completion, which includes keyword completion, using code templates

for completion and Content Assist to suggest completions for variable names, method names etc. while typing.

• Quick Fix, which allows to quickly resolve errors or warnings reported about the code.There are many quick fixes available for ABAP e.g.:

• Creating Method Implementations from the Method Definition • Creating Method Definitions from Implementation Parts • Creating Implementation Parts for Interface Methods • Creating Method Definitions from Method Calls

• Creating ABAP Classes or ABAP Interfaces from the Source Code … and many, many more.

(48)

Figure 32: Troubleshooting Tools – ABAP Debugger in Eclipse

Debugging ABAP Code

The latest ABAP debugger is completely integrated in the Eclipse debug framework. It is an ABAP debugger, but behaves like all other debuggers in Eclipse you might be familiar with because the look, feel, and functionality are all Eclipse. In other words, you can now debug your reports, transactions, classes, Web Dynpro applications etc. natively in Eclipse.

The ABAP Debugger in the ABAP Development Tools can satisfy most of your debugging requirements. For special purposes – other than observing running code – you may still want to use the New ABAP Debugger in the SAP GUI.

Note: The Run > Debug menu function in Eclipse is not enabled in the

ABAP perspective.

Start the debugger by setting a breakpoint in your code and then run the ABAP program, e.g. start it directly with F8.

The debugger offers, among other features editing in the debugger. You can correct a bug right when you find it. Debugging in the IDE is not supported if you are working with a 7.0 EHP3 backend system. For more information please visit the latest information on the Service Market Place.

(49)

Figure 33: Information Sources

If you want to get a local installation of the SAP Development Tools for Eclipse, there are several sources you can choose from, e.g.:

The SAP Software Download Center: http://service.sap.com/swdc, part of the SAP Service Marketplace.

The SAP Development Tools for Eclipse Web site: http://tools.hana.ondemand.com You can also find other products like the SAP HANA studio or the tools for SAP UI5 development via this site. It describes the how to install or update the SAP Development Tools for Eclipse using the SAP Development Tools for Eclipse Update Site.

Hint: A good idea is also to check the SAP Community

Network pages http://scn.sap.com/community/abap/eclipse and

http://scn.sap.com/community/abap/hana. They provide documentation and support on how to install the SAP Development Tools for Eclipse.

(50)

Figure 34: Installed Features

The About item in the Help menu provides information about installed features and plugins.

Figure 35: Installing and Updating Features

The Check for Updates and Install New Software commands in the Help menu provide the ability to update existing features and to find, download, and install new features (provided you configured suitable update sites in Eclipse).

(51)

Exercise 3: Create a Project in ABAP

Development Tools

Exercise Objectives

After completing this exercise, you will be able to:

• Open ABAP Development Tools and connect to an Application Server ABAP • Make a development package a favorite in your project

Business Example

Your company has recognized SAP HANA as an important strategic topic and has asked you to refresh your ABAP skills, paying particular attention to those required to develop or review code that leverages the strengths of SAP HANA.

Task 1: Create a Project in ABAP Development Tools

Open ABAP Development Tools and create a project in the Application Server ABAP that uses SAP HANA as primary database. Use the System ID, user and password provided by your instructor. Add your development package ZHA400_##, to the favorites of this project.

1. Open ABAP Development Tools (i.e. ABAP perspective in Eclipse). 2. Create a project. Use the system ID, user ID and Password provided by

your instructor.

3. Add your package ZHA400_## as a favorite under your project. 4. Using the ABAP Development Tools, create a report

ZHA400_##_HELLO_WORLD, where ## is your group

num-ber.

5. In your report, define a variable lv_name of type STRING with some constant value, and add a simple WRITE statement for this variable. Save the report. 6. Execute the syntax check via toolbar button (or STRG+F2). Activate and run

the report. To run, you can also press F8.

Task 2: Debug a report using ABAP Development

Tools

1. Set a breakpoint in your report.

2. Run the report again. This should result in a popup asking if you want to switch to the Debug perspective. Choose Yes.

(52)

3. Inspect the value of variable lv_name. 4. Resume execution.

(53)

Solution 3: Create a Project in ABAP

Development Tools

Task 1: Create a Project in ABAP Development Tools

Open ABAP Development Tools and create a project in the Application Server ABAP that uses SAP HANA as primary database. Use the System ID, user and password provided by your instructor. Add your development package ZHA400_##, to the favorites of this project.

1. Open ABAP Development Tools (i.e. ABAP perspective in Eclipse). a) Open SAP HANA Studio.

b) Change to the ABAP perspective using the pushbuttons in the upper right-hand corner.

2. Create a project. Use the system ID, user ID and Password provided by your instructor.

a) Right-click anywhere in the Project Explorer window on the left and choose New → ABAP Project.

b) Use the value help to choose one of the available connections and press the Next > button

c) Enter the client, user and password given to you by your instructor and press the Finish button

3. Add your package ZHA400_## as a favorite under your project.

a) In the Project Explorer, right click on Favorite Packages under your project and choose Add a Package....

b) Enter the name of your package and press the Ok button. 4. Using the ABAP Development Tools, create a report

ZHA400_##_HELLO_WORLD, where ## is your group

num-ber.

a) Select your package in the list of favorite packages, and choose context menu item New → ABAP Program.

b) Enter report name and description.

5. In your report, define a variable lv_name of type STRING with some constant value, and add a simple WRITE statement for this variable. Save the report. a) Write the report code as usual.

(54)

6. Execute the syntax check via toolbar button (or STRG+F2). Activate and run the report. To run, you can also press F8.

a) Press the toolbar button Check ABAP Development Object (or

Ctrl+F2).

b) Press the toolbar button Activate ABAP Development Object (or

Ctrl+F3).

c) Press the toolbar button Run As ... or F8. Select ABAP Application in the popup.

Task 2: Debug a report using ABAP Development

Tools

1. Set a breakpoint in your report.

a) Double-click in the grey column of a code line in the editor window to set the breakpoint.

2. Run the report again. This should result in a popup asking if you want to switch to the Debug perspective. Choose Yes.

a) Press the toolbar button Run As ... or F8.

b) In the Confirm Perspective Switch popup, choose Yes. 3. Inspect the value of variable lv_name.

a) The variable can be inspected in the Debug perspective, top-right view. 4. Resume execution.

a) Press the toolbar button Resume or F8. 5. Close the Debug perspective.

a) Open the context menu of the Debug perspective icon (top-right toolbar button) and choose item Close, or choose menu item Window → Close

(55)

Lesson Summary

You should now be able to:

(56)

Lesson: Introduction to the EPM Sample Application

Lesson Overview

This lesson introduces

• The Enterprise Procurement Model business example

• And the Open Item Analytics sample applications on which many of the exercises are based

Lesson Objectives

After completing this lesson, you will be able to:

• Describe the Enterprise Procurement Model business example • Describe the Open Item Analytics sample applications and which

computations it involves

Business Example

Your company ITeLO sells hardware to other companies, and purchases hardware or parts from other companies. ITeLO uses several ABAP applications, for example to classify customers according to their payment behavior, the total sales volume they generate, for dunning runs, financial account results and more. One of these applications is called Open Item Analytics and analyzes how long the customer invoices remain unpaid on average and per customer, the total open invoice amount per customer, and proposes which customer should receive a payment reminder.

Your company ITeLO wants you to improve the performance of this application considerably, by making use of SAP HANA.

Enterprise Procurement Model (EPM)

The ITeLO example described is part of a larger sample business scenario called Enterprise Procurement Model. This scenario has been introduced in SAP NetWeaver ABAP as a reference and show case for how to use newer technologies. Most SAP HANA courses use this scenario, and that‘s why it will also be used during a large part of this course.

(57)

Figure 36: The Enterprise Procurement Model Demo Scenario

As this course focusses on the sales and customer management part, having a closer look at the related master data and document data models is sufficient.

(58)

Figure 38: Document Data – Sales Order And Invoice

It allows switching between different ways how the analysis can be implement, especially in an ABAP system running on SAP HANA.

Figure 39: The Open Item Analytics Demo Application

One of ITeLO’s applications, the Open Item Analytics application, serves as the basis for many of the exercises that follow. The application determines, for each customer, the average age of the open (=unpaid) invoices, the total open invoice amount in €, and uses threshold values for both measures to propose which

(59)

Figure 40: Computations in the Open Item Analytics Demo Application

The application has to perform three computation steps, the first two of which are data-intensive and take considerably time when implemented the classical way in ABAP.

(60)

Lesson Summary

You should now be able to:

• Describe the Enterprise Procurement Model business example • Describe the Open Item Analytics sample applications and which

(61)

Unit Summary

You should now be able to:

• Describe SAP HANA goals, technical innovations and challenges • Understand the fundamental technical concepts of SAP HANA

• Explain the SAP HANA and ABAP evolution, architecture, and direction • Determine if HANA’s row store or column store is used for an ABAP

transparent table, and which indices are used on HANA • Explain the central functions of HANA Studio

• Switch between different perspectives in the SAP HANA Studio • Set up a connection to a SAP HANA database

• Understand schemata and tables in SAP HANA Studio • Analyze the definition of tables in SAP HANA Studio • Use the ABAP Development Tools in Eclipse

• Describe the Enterprise Procurement Model business example • Describe the Open Item Analytics sample applications and which

(62)
(63)
(64)
(65)

Unit 2

Taking ABAP to SAP HANA

Unit Overview

This unit is designed to teach the following topics:

• Access the SAP HANA Database using Open SQL and a secondary database connection

• Optimize Open SQL access to SAP HANA • Performance rules and guidelines for SAP HANA

Unit Objectives

After completing this unit, you will be able to:

• Describe how to access the SAP HANA Database by using Open SQL and a secondary database connection

• Use Code Inspector (SCI) and ABAP Test Cockpit (ATC) to locate potential functional and performance issues.

• Use the ABAP Trace (SAT) and the ABAP Profiling perspective to measure and compare runtime consumption

• Use the SQL Monitor (SQLM) to identify most important database access • Use the Performance Tuning Worklist (SWLT) to combine static and

dynamic performance analysis results

• Use SQL Trace (ST05) for in depth analysis of database accesses

• Understand the performance rules and guidelines for ABAP on SAP HANA

Unit Contents

Lesson: SAP HANA as Secondary Database – Access via Open SQL .. 55 Exercise 4: Access SAP HANA Via a Secondary Database

Connection ... 59 Lesson: Preparing for SAP HANA ... 69 Exercise 5: Improve Open SQL Using ABAP Test Cockpit (ATC) .... 79 Lesson: Guided Performance Analysis ... 90

Exercise 6: Use the SQL Performance Tuning Worklist to Analyze Static and Runtime Check Results ... 99

(66)

Exercise 7: Improve Open SQL Statements Using The SQL Trace (ST05) ...105 Lesson: Performance Rules and Guidelines for SAP HANA... 114

(67)

Lesson: SAP HANA as Secondary Database – Access

via Open SQL

Lesson Overview

Lesson Objectives

After completing this lesson, you will be able to:

• Describe how to access the SAP HANA Database by using Open SQL and a secondary database connection

Business Example

Your company has recognized SAP HANA as an important strategic topic and has asked you to refresh your ABAP skills, paying particular attention to those required to develop or review code that leverages the strengths of SAP HANA.

Secondary Database Connections

Each Application Server ABAP is connected to a Database Management System (DBMS) that contains the ABAP Repository and the database tables and views defined in this system's ABAP Dictionary. This DBMS is referred to as its Primary Database. Besides this primary database connection it is possible to establish connections to additional database management systems, so called Secondary

Database Connections. In the scenario SAP HANA as Accelerator, where SAP

HANA is used as a secondary DBMS, it is necessary to establish such a secondary database connection to SAP HANA.

(68)

Figure 41: Transaction DBACOCKPIT

Figure 42: Secondary database connections, among other things, are created and maintained via transaction DBACOCKPIT. Each database connection is identified by name that has to be unique within the application server.

(69)

Inside the connection, the DBMS is identified by a hostname and an instance number, which relates to an SQL port. Furthermore a database user (with password) has to be maintained. Any access to the database via this secondary database connection is equivalent to a log on to the database with this user.

Access to a Secondary Database with Open SQL

Once the secondary database connection is established, it is easy to use it in ABAP programs: Open SQL offers an addition CONNECTION which has to be followed by the name of the secondary database connection.

Figure 43: Open SQL Using Secondary Database Connection

But some restrictions apply, when using Open SQL to access a secondary database.

Figure 44: Open SQL over Secondary DB Connection – Restrictions

Because of the syntax check for Open SQL statements, the tables and fields the statement refers to, need to exist in the ABAP Dictionary of the application server.

(70)

This implies, that objects only known to SAP HANA (e.g. SAP HANA views or procedures) are not accessible by open SQL.

Note: We will learn later in this course, that in order to access these

objects, either native SQL has to be used or new objects have to be created in the ABAP Dictionary that make the SAP HANA objects visible for the syntax check.

Finally, Open SQL access to a secondary database is restricted to the default schema of the database user in the connection. Normally, the name of this schema is identical to the user name.

(71)

Exercise 4: Access SAP HANA Via a

Secondary Database Connection

Exercise Objectives

After completing this exercise, you will be able to:

• Understand how secondary database connections are maintained and tested • Understand the prerequisites for accessing tables of the secondary database

via open SQL

Business Example

Template: Report HA400_SEC_DB_CON_T1 Solution: Report HA400_SEC_DB_CON_S1

Task 1: Copy and understand templates

In SAP GUI, log on to the Application Server ABAP that does not have SAP HANA as a primary database. Create a copy of report HA400_SEC_DB_CON_T1 in your package ZHA400_## (suggested name: ZHA400_##_SEC_DB_1, where ## is your group number). Analyze the program code to get an idea of its functionality. Activate and execute the program.

1. Start SAP Logon and log on to the system labelled ZME on Sybase.

2. Create a copy of the report. Place it in your package ZHA400_## and assign it to your workbench request.

(72)

3. Analyze the source code of the program. Which are the two main parts of the data processing. In which processing blocks are they encapsulated?

4. The data comes from database tables and

. All columns but

one come from database table (column

). The remaining column is the result of a calculation. As input, this calculation uses two fields. These fields are

and of table

. The

calculated column returns the of

.

Fill in the blanks to complete the sentence.

5. Activate the program.

Task 2: Analyze

Look for a secondary database connection that points to the SAP HANA server. Find out which tables can be accessed with open SQL via this connection. 1. Look up the secondary database connections which have been maintained in

your AS ABAP.

Note: You do not need to change anything.

2. Find a database connection that points to your SAP HANA server and note down the DB user and connection name.

3. The connection name is and the DB user for the SAP

HANA server is .

Fill in the blanks to complete the sentence.

4. Go to SAP HANA Studio and open the schema with the same name as the user in the database connection.

(73)

5. Look for the tables you find in this schema. Those are the ones you can access via the secondary database connection using open SQL.

Hint: Tables starting with DD0 andRS_ are technical objects and

should not be considered here. They are used by the mechanism that replicates data from primary to secondary database.

6. Which are the tables that are of interest to the application programmer?

7. Verify for at least one table that the definition in the SAP HANA database is identical to the definition in the primary database.

Task 3: Access SAP HANA

Edit your program. Copy the source code of subroutine get_data_template to subroutine get_data_solution. In subroutine get_data_solution, make sure all SELECT-statements read from SAP HANA instead of the primary database. In all select statements of subroutine get_data_solution read from SAP HANA rather than the primary database.

1. Edit your program ZHA400_##_SEC_DB_1. Copy the source code of subroutine get_data_template to subroutine get_data_solution.

2. In subroutine get_data_solution, search for all SELECT-statements and use addition CONNECTION to access the secondary database rather than the primary database.

Hint: Instead of hard coding the connection, it is recommended

to define a constant of type dbcon_name (ABAP Dictionary data element).

(74)

Solution 4: Access SAP HANA Via a

Secondary Database Connection

Task 1: Copy and understand templates

In SAP GUI, log on to the Application Server ABAP that does not have SAP HANA as a primary database. Create a copy of report HA400_SEC_DB_CON_T1 in your package ZHA400_## (suggested name: ZHA400_##_SEC_DB_1, where ## is your group number). Analyze the program code to get an idea of its functionality. Activate and execute the program.

1. Start SAP Logon and log on to the system labelled ZME on Sybase. a) Perform this step as before.

2. Create a copy of the report. Place it in your package ZHA400_## and assign it to your workbench request.

a) Complete this step as you learned to do in previous classes.

3. Analyze the source code of the program. Which are the two main parts of the data processing. In which processing blocks are they encapsulated?

Answer:

1. Reading from the database and computing a list of customers, subroutine get_data_template.

2. displaying the list of customers, subroutine display. 4. The data comes from database tables SNWD_BPA and

SNWD_SO_INV_HEAD. All columns but one come from

data-base table SNWD_BPA (column CREATED_AT). The remaining column is the result of a calculation. As input, this calculation uses two fields. These fields are LV_CURRENT_DATE and CREATED_AT of table SNWD_SO_INV_HEAD. The calculated column returns the average age of open sales order invoices.

Answer: SNWD_BPA, SNWD_SO_INV_HEAD, SNWD_BPA,

CREATED_AT, LV_CURRENT_DATE, CREATED_AT, SNWD_SO_INV_HEAD, average age, open sales order invoices 5. Activate the program.

References

Related documents

The structure of the class website, including navigation, information provided, and use of the online LMS features (e.g., electronic submission of assignment, automated

In your examination, you find that the balance of Accounts Receivable represents sales of the current audit year only; that In your examination, you find that the balance of

AMI: Approximate measurement invariance; DIC: Deviance information criteria; DIF: Differential item functioning; EFA: Exploratory factor analysis; IRT: Item-response theory; LCA:

© SAP 2007 / Page 7 DB Internet DB Client (SAP GUI) Client (SAP GUI) Request for ABAP Request for JAVA JCO Central Services Enqueue- Server Central Services Message- Server

– Log backups are automatically written to Backint (if configured) SAP HANA 3 rd Party Backup Server 3 rd Party Backup Agent hdbsql SAP HANA studio Create backup.!. SAP HANA

 Log backups are automatically written to Backint (if configured) SAP HANA 3 rd Party Backup Server 3 rd Party Backup Agent hdbsql SAP HANA Studio Create backup... SAP HANA

Information related to the curricula of Punjab/Federal Boards, student activities, personnel evaluation methods, Government of Punjab employment rules, current data

By sketching some of the troubles and events happening in the local underground in 2011-2014, the Introduction then poses a question that constitutes the starting point of