Академический Документы
Профессиональный Документы
Культура Документы
TABLE of Contents
A. INTRODUCTION ........................................................................................................................................................ 3
YOUR SAP FIORI APP ....................................................................................................................................................... 4
B. ABAP DEVELOPMENT TOOLS ............................................................................................................................... 5
INTRODUCTION ................................................................................................................................................................. 5
SUMMARY EXERCISE B ................................................................................................................................................... 16
C. CORE DATA SERVICES (CDS).............................................................................................................................. 17
INTRODUCTION ............................................................................................................................................................... 17
SUMMARY EXERCISE C ................................................................................................................................................... 25
D. OPEN SQL ............................................................................................................................................................... 26
INTRODUCTION ............................................................................................................................................................... 26
SUMMARY EXERCISE D ................................................................................................................................................... 31
E. ABAP MANAGED DATABASE PROCEDURES (AMDP) ...................................................................................... 32
INTRODUCTION ............................................................................................................................................................... 32
SUMMARY EXERCISE E ................................................................................................................................................... 37
F. SAP GATEWAY....................................................................................................................................................... 38
INTRODUCTION ............................................................................................................................................................... 38
SUMMARY EXERCISE F.................................................................................................................................................... 50
G. SAP FIORI APPLICATION ...................................................................................................................................... 51
INTRODUCTION ............................................................................................................................................................... 51
SUMMARY EXERCISE G ................................................................................................................................................... 66
H. ADDITIONAL INFORMATION................................................................................................................................. 67
INTERFACE CDS VIEWS OF THE ENTERPRISE PROCUREMENT MODEL (EPM) .................................................................... 67
USEFUL ADT SHORTCUTS............................................................................................................................................... 68
2
DEV265
A. INTRODUCTION
Welcome to the exercises of the SAP TechEd Session DEV265. In this document you will find exercises on:
Before you start, here is some technical information on the system, usernames, passwords, etc. that you will need
during the exercise:
The screenshots for this exercise have been prepared using ABAP application user DEV265-300. The explanation
in this exercise will remind you to use your group number (indicated by #), e.g. ABAP program
ZR_DEV265_HELLO_WORLD_#. Moreover, you‟ll be creating ABAP artifacts in package ZDEV265EX_#, while all
screenshots show package ZDEV265EX_300 for illustration purposes.
You can find suggested solutions to the exercises in package ZDEV265_SOLUTIONS. As this is a hands-on exercise,
some of the exercises require a certain amount of coding ;-). If you like typing a lot, feel free to do so, if not, just run
transaction ZDEV265_CODING (guiding you to our Fiori application, referred to as the “CodingApp” in the following,
http://lt5088:51080/sap/bc/ui5_ui5/sap/zdev265_coding/index.html?sap-client=001).
3
DEV265
The customer list on the left-hand side categorizes business partners according to their number of open (yet-unpaid)
sales orders. Selecting one of the customers from this list, more information is retrieved and displayed on the right-
hand side of the application. This further information includes some more detailed information about the customer
including the currency-converted total gross amount of all open (yet-unpaid) sales order invoices and a distribution of
the best-selling products.
From the technical point of view, you‟ll use latest features of Open SQL, Core Data Services (CDS) views, and ABAP
Managed Database Procedures (AMDP). All these ABAP artefacts are used as input for a SAP Gateway OData
service, providing information for the SAP Fiori application.
4
DEV265
The ABAP Development Tools provide a set of powerful tools for developing ABAP applications. The tools
(Eclipse editors and Eclipse views) are ideally positioned in the IDE to facilitate your tasks. The diagram below
shows the default layout of the ABAP perspective:
5
DEV265
In this exercise you will get familiar with ADT, learning the basic concepts and interaction patterns so that you
can develop an end-to-end application from SAP HANA to SAP Fiori via ABAP.
Explanation Screenshot
6
DEV265
7
DEV265
Client: 001
User: DEV265-#
(# is your group number)
Password: Welcome15
8
DEV265
12.
9
DEV265
10
DEV265
11
DEV265
An embedded SAPGui
windows opens and displays
the result as depicted in the
screenshot.
12
DEV265
13
DEV265
14
DEV265
15
DEV265
Summary Exercise B
Congratulations, you finished the ABAP Development Tools exercise. You launched the “ABAP in Eclipse”
and created an ABAP Project. You even created an ABAP program, which is gone by now if you did the
optional exercise for deleting it .
This first exercise seems very tool-driven and you might ask: Is it mandatory in the context of ABAP
Development for SAP HANA? The answer is yes! You might have heard before (or will learn as we move
along), the ABAP Development Tools are mandatory for creating and maintaining ABAP artefacts like Core
Data Services (CDS) Views or ABAP Managed Database Procedures (AMDP) as you will see in the
following exercises.
16
DEV265
Introduction
The SAP Fiori application you‟re going to build shows the list of customers including their category on the left-hand
side. As indicated by the screenshot on page 4, this customer classification list is provided by means of a Core Data
Services (CDS) view.
This exercise introduces the CDS view definition capabilities of the AS ABAP 7.4. In particular, you will learn about
the features provided by ABAP CDS like aggregation functions and conditional expressions in the SELECT list,
Associations, the view-on-view capabilities, etc. The exercise is not designed to give you a complete list, but only a
peek into the long list of available features in ABAP CDS. Learn more about ABAP Core Data Services in the ABAP
language documentation.
As you will see in the following, the ABAP Development Tools will be used. CDS views, or more precisely Data
Definition Language sources (DDLS), can only be created and maintained using ADT, which is one of the reason
why we introduced the tools in detail in the previous exercise. Throughout the exercise, you‟ll see several useful tips
and tricks when working with the CDS editor.
Explanation Screenshot
17
DEV265
18
DEV265
19
DEV265
20
DEV265
21
DEV265
22
DEV265
23
DEV265
24
DEV265
Summary Exercise C
Well done! You enhanced an existing CDS view with an aggregation function and you further created a CDS
view from scratch. Using the view-on-view capabilities, a CASE expression and an associations available in
ABAP CDS. You provide the customer classification, which will later be used in the Fiori application. You
have not experienced how to consume a CDS view by means of Open SQL, you rather queried the CDS
views with the Data Preview provided in the ABAP Development Tools.
25
DEV265
D. OPEN SQL
Introduction
In the SAP Fiori application you‟re going to build, a customer can be selected from the customer classification list to
retrieve further information about the distribution of favorite/most ordered products. As indicated by the screenshot
on page 4, this product information is provided by means of Open SQL.
This exercise shows some of the features, that Open SQL recently learned. Introduction of these new features, e.g.
arithmetical functions, conditional expressions, literals, etc. in the SELECT list necessitated the introduction of a new
syntax – the most prominent change among these syntax enhancements is certainly the escaping of host variables
using the @ symbol. As was the case in the CDS exercise, we can only provide a peek into the long list of available
features, so you might want to have a look at the release-specific changes in the ABAP language documentation.
Explanation Screenshot
26
DEV265
27
DEV265
28
DEV265
29
DEV265
ZDEV265_I_Prod_Info_Sol
to retrieve the same
information.
30
DEV265
Summary Exercise D
Congratulations, you finished Exercise D. You successfully used the new Open SQL syntax to query CDS
views with and without input parameters and you used new features like the COALESCE function.
Now let‟s continue to learn about ABAP Managed Database Procedures (Exercise E), OData Services
(Exercise F) and Fiori applications in Exercise G.
31
DEV265
SAP HANA features procedural coding in form of Database Procedures. With the introduction of ABAP Managed
Database Procedures (AMDP), you can define and consume such database procedures directly within the ABAP
environment. Technically, the AMDP is a container for the database-specific coding – SQLScript in our example –
and the call of the database procedure looks identical to an ABAP class method call. Same holds for the lifecycle,
you merely transport the ABAP class method; the database procedure in the target system is then created by the
AMDP runtime.
One word of precaution, like native SQL, the coding within an AMDP is database specific, so you have to ensure that
you only call HANA-specific AMDPs when running on SAP HANA. Read more about AMDPs in the ABAP language
documentation.
Please note that the focus of this exercise is not to show you how to write SQLScript in the most performant way, but
rather to show you the concept of ABAP Managed Database Procedures from the ABAP developers perspective. For
more information about SQLScript, please have a look at the SAP HANA SQLScript Reference.
Explanation Screenshot
32
DEV265
4. The statement up to
“LANGUAGE” is inserted; let‟s
continue to define the
implementation language.
Start typing “s” and use the
code completion to insert
language SQLScript.
33
DEV265
34
DEV265
35
DEV265
36
DEV265
18. Congratulations, everything Result of calling the class method with an invalid currency :
worked fine! You might want
to repeat the test of your class
method for an invalid currency
like „USX‟ to investigate error
handling – something that will
be interesting for the Fiori App
in Exercise G as well.
Summary Exercise E
Perfect – another exercise done successfully! You implemented and ABAP Managed Database Procedure
and even learned how an AMDP can be called within another AMDP.
You have now finished all necessary preparation steps: you created CDS views, you used Open SQL to
provide data in a class method, and you implemented you first ABAP Managed Database Procedure –
great! For this end-to-end development example, this means you‟re ready to start with the implementation of
an SAP Gateway OData service which will provide the necessary data for your Fiori application!
37
DEV265
F. SAP GATEWAY
Introduction
The SAP Gateway (GW) is used as OData Service provider in our end-to-end development example. The OData
service is based on the entity relation model shown in the diagram below and the service implementations are based
on the ABAP class methods implemented in the previous exercises.
The entity CustomerClassification contains the fields Customer, CustomerName, Category, and information
about the address (StreetName, PostalCode, CityName, and Country). Moreover, CustomerClassification
contains the navigation properties ToCustomerInfo and ToProductInfo, which correspond to associations.
Following the associations, more detailed information about the customer like the currency-converted total gross
amount of all open (yet-unpaid) sales order invoices and a distribution of the best-selling products can be retrieved.
The process of following the association in the app corresponds to the action of selecting a customer from the
CustomerClassification list.
Explanation Screenshot
38
DEV265
39
DEV265
6. Provide ZDEV265_GW_# (#
your group number) as project
name and ZDEV265EX_# as
package name and continue.
40
DEV265
41
DEV265
42
DEV265
43
DEV265
44
DEV265
45
DEV265
Some explanations:
The information is only provided
for a given customer, thus an
exception is raised if the request
uses a direct access instead of
following the navigation property.
The information of the Customer
(input parameter for
get_customer_info of class
zcl_dev265_customer_info_
#) is provided via the
io_tech_reuqest_context-
>get_converted_source_keys
method. The local variable
lv_target_curr is set to USD
(you might want to change this
later to simulate an error in the
currency conversion).
The customer information for the
given Customer is retrieved from
the class method via the internal
46
DEV265
47
DEV265
48
DEV265
49
DEV265
Summary Exercise F
Congrats, you successfully created an OData Service, providing data from the SAP HANA database via
CDS views, Open SQL, and ABAP managed Database Procedures to the OData service. You used “Map to
Data Source” to bind the CDS View to the OData Service and you did the service implementations for the
ABAP class method calls, which in turn provide data via Open SQL or SQLScript (in the AMDP).
Now it‟s time to create a nice user interface and to provide the data via the OData service to this user
interface.
50
DEV265
Technically, the Fiori application is a split application constructed from a master and a detail part. On the master view,
the list of customer classifications is shown, while the detail view holds the customer information, total gross amount
information, and the product information.
Remark: The following step-by-step description uses the OData service ZDEV265_GW_#_SRV (for group number
#=300), representing the service you created in the previous exercise. You may alternatively use the service
ZDEV265_GW_SOL_SRV from the solution package. And for reference, you can have a look at the suggested solution
on http://lt5088.wdf.sap.corp:51080/sap/bc/ui5_ui5/sap/zdev265_coding/index.html (see Step 1 of Exercise G in the
CodingApp).
Explanation Screenshot
51
DEV265
52
DEV265
53
DEV265
54
DEV265
55
DEV265
56
DEV265
57
DEV265
58
DEV265
59
DEV265
60
DEV265
61
DEV265
62
DEV265
Back to the
Detail.view.xml, you‟d
have to add the texts as
shown on the screenshot
(Exercise G, Step9 in the
CodingApp).
63
DEV265
64
DEV265
65
DEV265
Summary Exercise G
Congratulations, you finally did it!
You created an SAP Fiori application based on your SAP Gateway OData service. You started with an SAP
Fiori Master Detail Application and added various descriptions, a bar chart diagram, and even OData
Service request failure messaging to the application. And throughout the exercises you saw the progress
while testing the application using the SAP Web IDE data preview.
Great, you have successfully joined us on our E2E development journey from HANA to Fiori via ABAP!
66
DEV265
H. ADDITIONAL INFORMATION
Interface CDS Views of the Enterprise Procurement Model (EPM)
67
Useful ADT Shortcuts
Edit
Ctrl+Shift+A Open development object
Ctrl+F2 Check development object
Ctrl+F3 Activate development object
Ctrl+Shift+F3 Activate all inactive objects
Ctrl+Space Code completion
Ctrl+1 Quick fix proposal
Ctrl+< Add comment
Ctrl+Shift+< Remove comment
Shift+F1 Format source aka pretty printer
Help
F1 ABAP keyword documentation
F2 Show code element information
Ctrl+3 Search for commands & views
Ctrl+Shift+L List all keyboard shortcuts
Navigate
F3 Open definition
Alt+Left Backward history
Alt+Right Forward history
Ctrl+T Quick hierarchy
F4 Open Type Hierarchy
Ctrl+O Quick outline
Ctrl+Shift+G Where-used list
Run, Debug
F8 Run current ABAP object
Alt+F8 Select & run ABAP application
Ctrl+Shift+B Toggle breakpoint
F5, F6, F7, F8 Step into, over, return, resume
© 2015
2014 SAP SE or an SAP affiliate company. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an SAP affiliate company. SAP
and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE (or an SAP affiliate company)
in Germany and other countries.
Please see http://www.sap.com/corporate-en/about/legal/copyright/index.html#trademark
http://www.sap.com/corporate-en/legal/copyright/index.epx#trademark for additional
for additional
trademark
trademark
information
information
and notices.
and notices.