2.4Getting Started in the Development System

Now that you’ve set up a development environment for ABAP development on SAP HANA, you can get started in the system. We’ll therefore provide you with sample developments that you can install on SAP NetWeaver AS ABAP 7.4 (as of SP 10, by using the description provided in Appendix E).

[»]Note

If this is your first time working with Eclipse, we recommend that you look at other sources of information in addition to this book. We’ll refer you to these additional sources at the relevant stages in this section.

2.4.1Basic Principles of Eclipse

Start the newly set up development environment as described in Section 2.3. Run the eclipse.exe program file for this purpose.

If the Welcome tab page is displayed when you start the program, use the button at the top-right of the screen to navigate to the Workbench. Choose WindowOpen Perspective to open the ABAP perspective. You should now see a screen similar to that shown in Figure 2.4. We’ll use this figure to explain the key elements of the Eclipse development environment.

Eclipse Workbench (with the ABAP Perspective Opened)

Figure 2.4Eclipse Workbench (with the ABAP Perspective Opened)

In Eclipse, you can work with one or more windows in parallel. If you want to open an additional window, choose the menu option, WindowNew Window.

Within a window, Eclipse only ever shows exactly one perspective at any given point in time. The name of the perspective currently displayed by the system is shown in the window’s title bar 1. A perspective describes the layout of screen elements for a particular purpose. For example, the ABAP perspective is available for ABAP development, while the Java perspective is available for Java development.

In the following text, we’ll discuss in detail the most important screen elements within a perspective:

Eclipse automatically saves any changes that you make to the screen elements of a perspective (e.g., layout and size). If you exit a perspective and then open it again (via the menu path, WindowOpen Perspective), the perspective will look exactly as it did when you exited it.

If you want to reset a perspective to its original state, choose the menu option, WindowReset Perspective. You can also create your own perspectives, if necessary, by choosing WindowSave Perspective As.

A view (2 and 3) makes certain information available to you. For example, the Problems view displays warnings and errors that occurred when you activated a program. You can view the properties of a program (e.g., title, package, and original system) in the Properties view and change them to some extent. To open a view, choose WindowShow View.

An editor 4 is used to edit a development object. Editors are frequently source code-based. However, form-based editors also exist.

[»]Differences between Views and Editors

When developers work with Eclipse for the first time, they often ask what the difference is between a view and an editor. The main differences between views and editors are as follows:

  • Within a window, a view can only be opened once, while an editor can be opened several times (e.g., to edit different programs in parallel).

  • Unlike a view, an editor can’t be positioned anywhere.

  • When an editor is open, it can be viewed in every perspective.

  • Changes within a view are saved immediately. Changes within an editor must be saved explicitly.

Further information is available at http://wiki.eclipse.org.

Menu bars and toolbars contain commands that you can execute in the current context (e.g., saving a program or activating a program). The main menu bar 5 is located at the very top of the Eclipse development environment. Views and editors can have additional menus, especially context menus (which you open by right-clicking). However, you can also add additional commands to the main menu bar.

The main toolbar is located below the main menu bar 6. Frequently used commands are located there. Views and editors can have additional toolbars. You can also add additional commands to the main toolbar.

Finally, we want to explain the purpose of workspaces. You likely noticed that the system prompted you to specify a workspace upon initial startup of the development environment.

Put simply, a workspace is a directory on your computer’s hard drive in which Eclipse stores your personal settings (e.g., layout and size of the screen elements in a perspective) and your project data (e.g., system connections to the ABAP AS). Eclipse only works with exactly one workspace at any given point in time. In the case of workspaces, you can configure the following settings:

Further information about Eclipse is available at www.eclipse.org/documentation/.

2.4.2ABAP Development Tools for SAP NetWeaver

We’ll now discuss the ABAP Development Tools for SAP NetWeaver in more detail. When working with the ABAP Development Tools, use the following views/perspectives:

In the ABAP backend, you require the relevant authorizations for working with the ABAP Development Tools. The following authorization roles are available by default:

Both roles contain the authorization object S_ADT_RES, which is needed for working with the Eclipse-based development environment. If you want to use your own roles to assign authorizations to ABAP developers, make sure that these roles consider the authorization object S_ADT_RES.

We’ll now explain the steps involved in creating a program with the ABAP Development Tools. We’ll provide some background information for each step as well.

Creating a Project

To work with the ABAP Development Tools, you need an ABAP project that connects the Eclipse-based development environment with the ABAP backend. To create an ABAP project, choose FileNewABAP Project, and then provide:

The project data is saved to your current workspace (see also Section 2.4.1). You can create any number of projects within a workspace and therefore work with multiple ABAP backends simultaneously.

After you’ve saved the project data, the ABAP project is displayed in the Project Explorer view (2 in Figure 2.4). A tree structure is displayed below your project, and the uppermost level of this tree structure contains the following two nodes:

If you double-click a development object in Project Explorer, the relevant editor opens. In addition, the Outline view 3 displays the structure (e.g., the global variables and methods for a program), while the Properties view displays the properties of the development object. Not all development objects have an editor that is implemented natively in Eclipse. If a development object doesn’t have an editor, the SAP GUI opens. For a data element, Transaction SE11 (ABAP Data Dictionary) opens, for example. The Outline and Properties views aren’t available in this case.

You can use SAP GUI integration to execute any development objects in the SAP GUI, even if they aren’t displayed in the Project Explorer view at present. To do this, choose RunRun ABAP Development Object, and select the relevant development object. This is particularly useful if you want to execute a standard program or transaction (e.g., Transaction SM50).

ABAP resource URLs are interesting for all development objects, irrespective of whether the ABAP Development Tools provide native editor development objects. They enable you to generate hyperlinks for development objects and integrate them into websites or emails, for example. You can click the hyperlink to open the relevant development object directly in the ABAP Development Tools.

To generate an ABAP resource URL, choose Share Link from the context menu of a development object (or choose Share Link for Selection in the source of a development object). Note that you can’t open a development object via a hyperlink unless you’ve registered your Eclipse installation. Keep reading for more information.

Unlike other Eclipse-based development tools, the ABAP Development Tools don’t use a check-in/check-out mechanism. As a result, you can’t work with the ABAP Development Tools offline (i.e., without a connection to the ABAP backend). As soon as you edit a development object, this is automatically locked against editing by another user. Therefore, unlike in the SAP GUI, you don’t explicitly toggle between Display and Change. The following tasks always occur in the ABAP backend: save, perform syntax check, and activate.

User-Specific Settings

You should be familiar with choosing UtilitiesSettings to configure user-specific settings in the ABAP Workbench, and therefore adjust the (SAP GUI-based) development environment to your personal requirements.

In Eclipse, user-specific settings are available under WindowPreferences. Many of the options provided here are general settings for Eclipse. They aren’t specifically used for ABAP development but influence it nonetheless. The specific settings for the ABAP Development Tools are available under the ABAP Development node (see Figure 2.5).

User-Specific Settings for ABAP Development Tools

Figure 2.5User-Specific Settings for ABAP Development Tools

You should be familiar with the following setting options:

Creating a Program

The next step is to create a new development object by choosing FileNew. If you want to create a program that outputs the flight schedule for a given airline, for example, choose FileNewABAP Program. Then enter the program name, title, and package. Select a transport request, if necessary.

The editor for the program now opens. As an example, insert the source code from Listing 2.1.

REPORT zr_a4h_chapter2_first_report.

DATA: lt_spfli TYPE STANDARD TABLE OF spfli, "#EC NEEDED
lv_spfli TYPE string. "#EC NEEDED
FIELD-SYMBOLS: <ls_spfli> TYPE spfli. "#EC NEEDED
PARAMETERS: p_carr LIKE <ls_spfli>-carrid OBLIGATORY.
SELECT * FROM spfli UP TO 50 ROWS INTO TABLE lt_spfli
WHERE carrid = p_car. "this line contains
"a syntax error
LOOP AT lt_spfli ASSIGNING <ls_spfli>.
lv_spfli = |{ <ls_spfli>-carrid } | &&
|{ <ls_spfli>-connid } { <ls_spfli>-airpfrom } | &&
|{ <ls_spfli>-airpto }|.
WRITE: / lv_spfli.
ENDLOOP.

Listing 2.1Simple ABAP Program

[»]Note on Listing 2.1

To restrict the program runtime, use the UP TO n ROWS addition. Consequently, the program doesn’t output the entire flight schedule. Instead, it outputs a maximum of 50 connections.

When editing the source code, you’re supported by numerous functions in ABAP Development Tools (just like in the SAP GUI), including the following three functions:

When editing the source text, you can perform a syntax check at any time by pressing (Ctrl)+(F2).

As shown in Figure 2.6, warnings and errors are displayed in both the Problems view and in the editor (specifically in the left and right column spaces). For Listing 2.1, the syntax check should issue a reminder about an error in program line 8. Correct this error.

Result of the Syntax Check

Figure 2.6Result of the Syntax Check

If you want the source text to undergo more extensive checks, you can use the ABAP Test Cockpit for this purpose. To do this, call the context menu in your program: Run AsABAP Test Cockpit.

Following a successful syntax check, choose FileSave to save your program (in principle, you can also save erroneous development objects). When you save your program, an inactive version of the program is generated in the ABAP backend.

If you then choose EditActivate to activate the program, an active version of the program is generated in the ABAP backend (assuming that the program doesn’t contain any syntax errors).

As a result of your work with the ABAP Workbench, you have no doubt become familiar with—and have come to appreciate—the extensive navigation options available there. Forward navigation and the where-used list are also available to you in the Eclipse-based development environment.

For forward navigation, select an identifier in the source text, and choose NavigateNavigate To (or press the (F3) key). For our sample program, you can execute the following actions:

The where-used list works in the same way. First, select an identifier in the source text. Then, choose Get where-used list in the context menu. The result of the where-used list is displayed in the Search view (see Figure 2.7).

Result of the Where-Used List

Figure 2.7Result of the Where-Used List

You can double-click a line in the result to navigate to where the object is used.

Executing the Program

Now that you’ve learned how to create a program and are familiar with the editing options available in the ABAP Development Tools for SAP NetWeaver, you’ll most likely want to execute the program for testing purposes. To do this, choose Run As • ABAP Application from the program’s context menu, and execute the sample program shown earlier in Listing 2.1. The selection screen for the program is then displayed in the SAP GUI. Here, enter the code of an airline. Press (F8) to display the corresponding flight schedule.

If you want to debug a program to analyze program errors, you can set one or more breakpoints in the ABAP Development Tools. Here, you can choose between static and dynamic breakpoints:

Figure 2.8 shows how static breakpoints are displayed in the left column space in the editor and in the Breakpoints view. Dynamic breakpoints are displayed in the Breakpoints view only.

Displaying Breakpoints That Have Been Set

Figure 2.8Displaying Breakpoints That Have Been Set

From a technical perspective, the ABAP Development Tools work with external breakpoints. These apply to all programs in your current user session, which are executed under your user on one of the application servers on the ABAP backend (defined by the system and client in the ABAP project).

If the system encounters a breakpoint when executing a development object, it automatically opens the Debug perspective. Similar to the SAP GUI-based debugger, you can analyze the call hierarchy and the contents of the variables, as well as debug the source code step by step. Figure 2.9 shows the Debug perspective for our sample program.

Debug Perspective

Figure 2.9Debug Perspective

The following are some additional sources of information related to the ABAP Development Tools:

You’re now ready to use the ABAP Development Tools for SAP NetWeaver. In the next section, we’ll introduce you to SAP HANA Studio.

2.4.3SAP HANA Studio

Just like the ABAP Development Tools for SAP NetWeaver, SAP HANA Studio also includes different perspectives:

Similar to working with AS ABAP, you require the relevant authorizations for working with SAP HANA Studio, specifically in the SAP HANA database.

[»]Authorizations in SAP HANA

The authorizations in SAP HANA are divided into the following areas:

Authorizations can be grouped into roles or assigned directly to users.

We won’t discuss the authorization concept for the SAP HANA database in detail here. Instead, we’ll focus on the authorizations that you require, as an ABAP developer, to work with SAP HANA Studio.

If you’re already working with ABAP release 7.4 and using the SAP HANA database as the primary persistent storage, you can use the following standard roles to assign authorizations to ABAP developers who will work with SAP HANA Studio:

In this section, we’ll focus on the SAP HANA Modeler perspective, which is relevant for you as an ABAP developer. Based on this, Chapter 4 will provide more detailed information.

Creating a System Connection

To work with SAP HANA Studio, you require a system connection between SAP HANA Studio and the SAP HANA database. You can create a system connection in the SAP HANA Modeler perspective, for example. In the Systems view, use the Add System option in the context menu for this purpose. Then, provide the following information for the system connection:

The system data is saved to your current workspace (see also Section 2.4.1). You can create any number of system connections within a workspace. This enables you to work with multiple databases simultaneously.

After you’ve saved the system data, the system connection is displayed in the Systems view (see Figure 2.10).

Modeler Perspective in SAP HANA Studio

Figure 2.10Modeler Perspective in SAP HANA Studio

A tree structure is displayed below your system connection, and the uppermost level of this tree structure contains the following four nodes:

User-Specific Settings

Similar to the ABAP Workbench or ABAP Development Tools, you can also configure some user-specific settings in SAP HANA Studio. The relevant settings for the SAP HANA Modeler perspective are located under Window • Preferences • SAP HANA • Modeler. Of particular interest here are the data preview settings (under the Data Preview node) and the rules for validating development objects (under the Validation Rules node).

Working with the Database Catalog

The database catalog in the SAP HANA database has a similar structure to the catalogs in other databases. It manages the database objects in database schemas (2 in Figure 2.10). A schema groups logically related database objects together (comparable with a namespace). In principle, each database user has his own database schema.

The ABAP application server generally uses exactly one technical database user to communicate with the database. This user also has a corresponding database schema, known as the system schema or ABAP schema (for more information, see Chapter 3, Section 3.1). In Figure 2.10, this is schema SAPS74.

Some database schemas are used internally by the SAP HANA database. In particular, these include the database schema SYS and all database schemas that start with _SYS.

[»]Technical Database Schemas in SAP HANA

Immediately after the installation, SAP HANA contains a set of database schemas that play a major role in different scenarios, so we’ve included some background information about some of the schemas used internally by the SAP HANA database:

Database schemas contain database objects. The SAP HANA database recognizes the database objects listed in Table 2.1.

Object

Description

Column View

Column views are special views in SAP HANA based on tables in the column store and are usually created in the SAP HANA Repository.

Function

A user-defined function performs calculations and can be integrated into SELECT statements.

Index

An index facilitates searches and sorting. Note the information about indexes in Chapter 10 and Chapter 14.

Procedure

You can use database procedures to encapsulate and reuse algorithms that are to be executed in the SAP HANA database. Further information is available in Chapter 6.

Sequence

You can use a sequence to generate unique, consecutive numbers in accordance with certain rules. This concept is very similar to number ranges in ABAP.

Synonym

Synonyms can be defined as aliases for database tables, data views, procedures, and sequences. We’ll discuss these later in this chapter.

Table

Data is saved to database tables. As part of your ABAP development work in SAP HANA, you frequently use the ABAP Data Dictionary (DDIC) to create database tables.

Trigger

Database triggers are functions called for certain changes made in the database.

View

Views are saved queries (across one or more tables) that can be called via SQL in the same way as a database table.

Table 2.1Objects in the Database Catalog

As part of your ABAP development work in SAP HANA, you generally won’t create any database objects directly in the catalog. You’ll typically create objects only indirectly, for example, via the DDIC, SAP HANA Repository, or SAP Landscape Transformation Replication Server (SAP LT Replication Server). In certain circumstances, however, you may want to view database objects directly in the catalog. We’ll now use the example of table SPFLI, which you already used in Listing 2.1, to explain how this works.

Open the ABAP schema under the Catalog node. Here, you see nodes for the different database objects. If you want to search for a specific database table, choose the Find Table option in the context menu for the Tables node. Then, enter “SPFLI” in the search dialog box. Make sure that the Show definition checkbox is set, and choose OK.

The system now opens the table definition (see Figure 2.11). Here, you see that table SPFLI uses column-oriented data storage (known as the column store). You can also check columns, indexes, and runtime information for the database table, among other things.

Similar to the table definition, you can also use the Find Table option in the context menu to display the table contents. Alternatively, you can use the context menu for the Tables node to set a filter for the table name. The Navigator view then displays only those tables that satisfy the filter condition. You can now right-click to select the Open Content option in the context menu. Note that the system displays only the first 1,000 data records (and not the entire contents of the database table).

Table Definition Using the Example of Table SPFLI

Figure 2.11Table Definition Using the Example of Table SPFLI

You can use the data preview to analyze more than 1,000 data records. To access the data preview, choose the Open Data Preview option in the context menu. Figure 2.12 displays the data preview using the example of table SPFLI.

The data preview comprises the following tab pages:

Data Preview Using the Example of Table SPFLI

Figure 2.12Data Preview Using the Example of Table SPFLI

We’ll now introduce you to one more tool—the SQL console—that can be very useful when working with the database catalog. This enables you to quickly and easily execute read and write SQL statements on the SAP HANA database. If, for example, you want to add the name of an airline to the flight schedule from Section 2.4.2, you can use a join (see Chapter 3). You can test the JOIN statement (see Listing 2.2) in the SQL console. To open the SQL console in the Navigator view, choose the Open SQL Console option in the context menu for the ABAP schema. You can then enter the relevant SQL statement. Similar to the ABAP Development Tools, you can also use (Ctrl)+(Space) to revert to code completion and templates.

select spfli.carrid, scarr.carrname, spfli.connid,
spfli.airpfrom, spfli.airpto
from spfli
join scarr on scarr.carrid = spfli.carrid;

Listing 2.2Simple Join

Then, choose Execute to execute the SQL statement. The result is shown in Figure 2.13. In addition to the result list, the system provides some information about the runtime and number of data records read.

SQL Console

Figure 2.13SQL Console

If you enter several SQL statements in the SQL console, each separated by a semicolon, you can execute them by choosing Execute once. If you want to execute only one or some of the SQL statements, select them before you choose Execute.

Working with the SAP HANA Repository

This brings us to the SAP HANA Repository, which helps to organize development objects (known as content) in a flexible and expansible manner. The development objects contained in the SAP HANA Repository are organized along a package hierarchy. In terms of their notation and significance, these packages are very similar to Java packages. Because a package defines a namespace, the identifier for development objects must only be unique within the package (unlike the global uniqueness of the identifiers for ABAP objects).

SAP delivers content below the sap root package. Parallel to this package, you can establish your own package hierarchy for your development objects. You can group multiple packages together to form a delivery unit, which you can then transport. We’ll examine the package concept and application transport in detail in Chapter 5.

In the Modeler perspective, you can create the development objects described in Table 2.2. These are also known as content types.

Object

Description

Package

A package groups development objects together. We’ll discuss this in Chapter 5, Section 5.3.1.

Attribute View

You can use attribute views to connect multiple database tables or to select a subset of the columns in a database table. For more information, see Chapter 4, Section 4.4.1.

Analytic View

In particular, you use analytic views to quickly aggregate data. Details are available in Chapter 4, Section 4.4.2.

Calculation
View

Calculation views are available for requirements that can’t be mapped using attribute views and analytic views. They can be modeled or implemented using SQLScript. Details are available in Chapter 4, Section 4.4.3.

Analytic
Privilege

You can use analytic privileges to restrict—line by line—access to views.

They aren’t directly relevant for access from ABAP because this is done using a technical database user.

Procedure

You can use database procedures to encapsulate and reuse algorithms that are to be executed in the SAP HANA database. More information can be found in Chapter 4, Section 4.3.

Decision Table

You can use decision tables to store business rules in SAP HANA. We’ll discuss this in Chapter 11.

Table 2.2Development Objects in the SAP HANA Repository

You can create additional development objects in the SAP HANA Development perspective. This is particularly relevant for any development work based on SAP HANA XS. For the moment, we won’t discuss these development objects further.

We’ll now use a specific example to explain some key concepts associated with the SAP HANA Repository: Figure 2.14 shows the editor for the attribute view AT_FLIGHT_SCHEDULE in the package test.ah4. book.chapter02.

Attribute View AT_FLIGHT_SCHEDULE

Figure 2.14Attribute View AT_FLIGHT_SCHEDULE

Without discussing the specific features of attribute views, we’ll explain the following concepts:

Each development object in the SAP HANA Repository is described by different properties (1 in Figure 2.14), some of which you can specify when creating the object, and some you can also change later. Examples include the unique identifier within the package (Name), description (Label), and Default Client. Other properties are automatically set by the system, for example, the last user who changed the object (Changed by).

The system creates an XML file for each development object and ultimately stores it as a Character Large Object (CLOB) data type in the database schema _SYS_REPO. You can choose Display XML to display the XML file for an object 2.

Figure 2.15 shows the XML representation of the attribute view AT_FLIGHT_SCHEDULE. In this figure, we’ve highlighted some parts of the XML document, namely the identifier for the view, the description of the view, the columns in the view, and the database table underlying the view.

XML Representation of an Attribute View

Figure 2.15XML Representation of an Attribute View

Similar to ABAP development objects, the development objects in the SAP HANA Repository also have a status (either Inactive or Active). If you create a new object or change an existing object, the system generates an inactive version first.

You can validate an object before you activate it. In addition to syntax checks (e.g., correct syntax of SQLScript within a database procedure), the validation can also consider some aspects of quality (e.g., performance). This is similar to the (enhanced) syntax check in ABAP. We’ll discuss some of these aspects in greater detail in Chapter 14.

To start validation, choose Save and Validate changes to this object. The validation result is displayed in the Job Log (3 in Figure 2.14). If warnings or errors occur when validating an object, you can display them by double-clicking the corresponding row in the job log.

Figure 2.16 shows an example of what would happen if you were to validate the attribute view AT_FLIGHT_SCHEDULE without defining at least one key attribute first. This is a mandatory requirement for attribute views.

Job Details with Validation Errors

Figure 2.16Job Details with Validation Errors

When you activate an object, you generate an active (i.e., executable) version of a development object. An object is automatically validated when it’s activated. To start activation, choose Save and Activate. The result is displayed in the job log.

Following successful activation, the system usually generates one or more database objects in the schema _SYS_BIC. The development objects in the SAP HANA Repository represent the design time objects, while the database objects in the database catalog represent the runtime objects (see Figure 2.17).

Design Time and Runtime

Figure 2.17Design Time and Runtime

[»]Authorizations for the User _SYS_REPO

The internal user _SYS_REPO (the owner of the SAP HANA Repository) generates the runtime objects in the database schema _SYS_BIC. This user must have read access to the schemas used in the development objects. In other words, the user requires the SQL SELECT with GRANT authorization on the schema.

For the attribute view AT_FLIGHT_SCHEDULE, the system generates (among other things) a column view and a public synonym for this column view in the database catalog. A column view is a special data view in SAP HANA. In our example, the name of the column view comprises the package and identifier for the attribute view (see Figure 2.18).

A synonym is an alias. A public synonym is an alias that is unique across all database schemas and can be used by all users. If, for example, you use the relevant public synonym to access the column view, you avoid having to name the schema _SYS_BIC explicitly. In our example, the name of the public synonym comprises the package and name of the attribute view (see Figure 2.19).

Runtime Object for an Attribute View

Figure 2.18Runtime Object for an Attribute View

Public Synonym for a Column View

Figure 2.19Public Synonym for a Column View

When you want to test objects in the SAP HANA Repository, it’s best to use the data preview and the SQL console. You’re already familiar with both of these tools, which we explained when we discussed the database catalog previously. To start the data preview for a development object, choose Data Preview. This preview is available for attribute views, analytic views, calculation views, and decision tables.

Because we’ve already used the example of database table SPFLI to explain the data preview, we won’t discuss it in further detail here. However, take a look at the Show Log button in the data preview. You can use this button to call a selection log, which helps you quickly find the corresponding runtime object for a design time object (see Figure 2.20). This enables you to determine the runtime object for a development object.

Selection Log with a Database Object

Figure 2.20Selection Log with a Database Object

Alternatively, you can conduct tests directly in the SQL console. In our example, you can use the following objects here: the name of the column view generated (i.e., test. a4h.book.chapter02/AT_FLIGHT_SCHEDULE in the schema _SYS_BIC) and the public synonym (test.a4h. book.chapter02:: AT_FLIGHT_SCHEDULE).

Similar to ABAP, development objects are put under version control. Each time an object is activated, the system creates a new version of the object. You can display existing versions in the version history. To access the version history, choose History. However, you see only the time when a version was created (i.e., the time when an object was activated). You can’t see the actual changes made to each version.

If there is an inactive version, you can choose Switch Version to execute the following actions:

You now know the relevant tools for ABAP development on SAP HANA, and you’ve taken your first steps toward getting started in the system. In the next chapter, we’ll discuss ABAP database programming. For more information on working with SAP HANA Studio, see Chapter 4.