Sunteți pe pagina 1din 11

Topic 8: Consuming HANA views in ABAP

1 Module Name: 1. HANA Overview 2013 IBM Corporation


Procedure Overview

A HANA Attribute View will be created in Step 1, but note that the two following steps (1 and 2) are identical for a HANA
Calculation View and a HANA Analytical View

Native SQL Syntax How to fetch


data using SQL statement from
Logical picture of consuming SAP external views
HANA view

2 Module Name: 1. HANA Overview 2013 IBM Corporation


Expose a HANA View as External View in the ABAP Dictionary
We will expose the previously created HANA view in the application server using the new ABAP dictionary
feature called External View.

Open the ABAP perspective. Select


menu entry Window > Open perspective
> Others, then choose from the dialog
and press OK.

Create the dictionary view (View Type:


External View) ZAT_OIA_OPENDAYS
in the ABAP dictionary. Right-click the
package of your choice and choose
context menu entry New > Other ABAP
Repository Object. (I will use my $TMP
package for this purpose.)

Enter a name (e.g.


ZAT_OIA_OPENDAYS) and a
description (e.g. External view:
Retrieve sales orders with open days
and bupa data). Choose the External
View radio button, enter the name of the
HANA Attribute View previously created
in Step 1 (e.g. system-
local.private.demo.AT_OIA_OPEN_DA
YS) and press Next.

3 Module Name: 1. HANA Overview 2013 IBM Corporation


Expose a HANA View as External View
On the next dialog box, select a transport request if required and press Finish.

Save and activate the new External View.

Note:
The new ABAP dictionary features are only available in the ABAP Development Tools for SAP NetWeaver
(ABAP in Eclipse) and not in the standard ABAP Workbench (transaction SE80). The procedure described
below Exposing a HANA view as External View in the ABAP Dictionary- is valid for all three types of SAP
HANA views, meaning Attribute Views, Calculation Views and Analytical Views.
4 Module Name: 1. HANA Overview 2013 IBM Corporation
Expose a HANA View as External View
Information about External View
An External View only represents the HANA view from which it is derived. In particular, this means that the
HANA view is the leading object: changes made to the fields in the view in the HANA Repository imply
changes for the external view (in ABAP Dictionary) and all consumers.

Information about synchronizing contents with the SAP HANA Repository in the External View,
press the "Synchronize" button to reload the metadata of the underlying HANA view if it was changed in
the HANA repository. Do not forget to save and activate the updated dictionary object afterwards.
You can preview an external view in the ABAP dictionary (SE11 and SE16) like you do for any other
classical dictionary view or database.

5 Module Name: 1. HANA Overview 2013 IBM Corporation


ABAP Report consuming an External View

We will now create and implement a simple ABAP report which read the resulting dataset via the External
View in open-SQL and display the resulting dataset using the standard ALV.
1. Create ABAP program ZR_OIA_OPEN_DAYS. Select the package of your choice, right-click on it and
choose context menu entry New > ABAP Program.

2. Enter a name (e.g. ZR_OIA_OPEN_DAYS), a description (e.g. Retrieve and Display Sales Order with
Open Days and BuPa Data) and press Next. On the next dialog screen, select a transport request if
required and press Finish.

6 Module Name: 1. HANA Overview 2013 IBM Corporation


Data Type Compatibility SAP HANA
String Data
specifies a varying-length ASCII character string. The maximum length is an integer between
VARCHAR(n)
15,000 characters.
specifies a varying-length Unicode character set string. The maximum length is an integer
NVARCHAR(n)
between 15,000 characters.
specifies a varying-length character string that contains alphanumeric characters. The
ALPHANUM
maximum length is an integer between 1127 characters.
specifies a varying-length character string that supports text-search and string-search
SHORTTEXT features. It is not a stand-alone SQL data type. Selecting a SHORTTEXT(n)-length column
yields a column of type NVARCHAR(n).

Binary Data
specifies a varying-length binary string that stores binary data of a specified maximum length
VARBINARY
in bytes. The maximum length is an integer between 15,000 characters.

Large Object (LOB) Data


BLOB (binary large
stores large binary data.
object)
CLOB (character
stores large ASCII character data.
large object)
NCLOB stores a large Unicode character object.
supports text-search features. It is not a stand-alone SQL data type. Selecting a TEXT-column
TEXT
yields a column of type NCLOB.

7 Module Name: 1. HANA Overview 2013 IBM Corporation


Data Type Compatibility SAP HANA
Numeric Data
TINYINT stores an 8-bit unsigned integer. Values range from 0 through 255.
SMALLINT stores a 16-bit signed integer. Values range from 32,768 through +32,767.
INTEGER stores a 32-bit signed integer. Values range from 2,147,483,648 through +2,147,483,647.
BIGINT stores a 64-bit signed integer. Values range from 9,223,372,036,854,775,808 through +9,223,372,036,854,775,807.
DECIMAL(precision,sc specifies a fixed-point decimal number with precision p and scale s. The precision is the total number of significant
ale) or DEC(p,s) digits. Values can range from 1 through 34.
specifies a floating-point decimal number. The precision and scale can vary within the range, 1~16 for precision and
SMALLDECIMAL
369~368 for scale, depending on the stored value. SMALLDECIMAL is supported only on column store.
REAL specifies a single-precision 32-bit floating-point number.
specifies a single-precision, 64-bit floating-point number. Values can range from 1.79769 x 10308 through +1.79769 x
DOUBLE 10308. The smallest positive DOUBLE value is +2.2207 x 10308 and the largest negative DOUBLE value is
2.2207 x 10308.
specifies a 32-bit or 64-bit real number, where n specifies the number of significant bits. It can range from 1 through 53.
FLOAT(n) When you use FLOAT(n), if n is smaller than 25, it becomes a 32-bit REAL data type. If n is greater than or equal to
25, it becomes a 64-bit DOUBLE data type. If you do not declare n, by default, it becomes a 64-bit double data type.

Date, Time, and Timestamp Data

DATE specifies month, day, and year information to represent a date value. The range is 01-01-0001 to 12-31-9999. The
default format is YYYY-MM-DD

TIME specifies hour, minute, and second information to represent a time value. The default format is HH24:MI:SS (for
example, 20:34:17).

SECONDDATE specifies year, month, day, hour, minute, and second information to represent a date with time value. The default
format for the SECONDDATE data type is YYYY-MM-DD HH24:MI:SS

TIMESTAMP specifies date and time information. The default format is YYYY-MM-DD HH24:MI:SS.FFn (for example, 1967-06-13
20:34:17.FF7). FFn represents the fractional seconds, through 9999-12-31 23:59:59.9999999.

8 Module Name: 1. HANA Overview 2013 IBM Corporation


ABAP Report consuming an External View
Implement the report. Copy & paste the source code below into the ABAP editor.

Note:
Analogous to other regular dictionary views, external views are called using the SELECT statement (Open
SQL). Meaning no special ABAP statement has to be called like it is the case for Database Procedure
Proxy entities where statement CALL DATABASE PROCEDURE has been added to the ABAP language.

9 Module Name: 1. HANA Overview 2013 IBM Corporation


ABAP Report consuming an External View
You can now run the report (press F8) and see the result of your effort.

10 Module Name: 1. HANA Overview 2013 IBM Corporation


Summary

You can now create a HANA (Attribute) View, expose it as External View in the ABAP dictionary and
access the view natively in your ABAP program.
The illustration below provides the high level architecture underlying this tutorial.

11 Module Name: 1. HANA Overview 2013 IBM Corporation

S-ar putea să vă placă și