Professional Documents
Culture Documents
Exercises/Solutions
Volker Drees / SAP SE
INT260
TABLE OF CONTENTS
2 Develop an OData Model using the OData Model Editor plugin ............................................. 4
2.1 Logon to the SAP HANA Cloud Platform, start the SAP Web IDE and enable
the OData Model Editor ................................................................................................................. 4
2.2 Develop the base OData Model using the OData Model Editor ........................................... 8
3.1 Create a SAP Gateway Service Builder project and perform the provisioning
using CDS views ........................................................................................................................... 19
3.2 Register and Test the OData service using the Gateway client ........................................... 28
3.3 (Optional) – Implement a default sorting for the Business Partner entity set ....................... 31
4.1 Define an individual Destination in the SAP HANA Cloud Platform Cockpit. ....................... 36
4.4 Add a default sorting for the business partner list ................................................................ 46
4.5 Add properties from the existing OData model to the application ........................................ 49
5.1 Enable the update operation of the BusinessPartnerSet entity set ...................................... 52
5.2 Test the update operation using the Gateway client ............................................................ 56
7.1 Enhance the OData model to provide the analytical data .................................................... 78
7.2 Add another tab to the application showing the chart data .................................................. 83
7.3 (Optional) – Launch the application on your smartphone using the QR code ..................... 86
2
INT260
In the session INT260 you will develop an OData V2 service from scratch, starting with the OData
model definition. The data model that is used in this session is based on the NetWeaver Enterprise
Procurement Model (EPM), which is an application intended to be used for demonstration and testing
purposes.
The initial OData model consists of two entity types and will be developed using the OData Model
Editor plugin in the WebIDE. You will import this data model into a SAP Gateway Service Builder
project and provision the service using predefined ABAP CDS-views.
After a successful testing of your OData service in the Gateway Client you will use the service to
generate a Fiori-like application based on the WebIDE Master/Detail template.
In the subsequent exercises you will further enhance your SAPUI5 application as well as the
underlying SAP Gateway OData service. You will for instance:
Chapter 2: Develop an OData Model using the OData Model Editor Plugin in the SAP Web IDE
Estimated Duration: 35 minutes
3
INT260
Overview
Estimated time: 30 minutes
Objective
The objective of this chapter is to develop the initial OData Model that will be used as a basis for all
subsequent chapters. The initial data model will be developed using the OData Model Editor and it will
consist of two entity types.
Exercise Description
You will log on to the SAP HANA Cloud Platform (HCP) and access the SAP Web IDE. Inside the SAP
Web IDE you will use the OData Modeler Plugin to develop the data model that will be extended in the
course of the INT260 session.
The trainer will provide you a valid P-User and a password to logon to the SAP HANA Cloud Platform
Cockpit. Please note that we’ve prepared individual SAP HANA Accounts per Data Center location.
For the SAP TechEd 2015 in Las Vegas you’ll have to use: https://account.us1.hana.ondemand.com
For the SAP TechEd 2015 in Barcelona you’ll have to use: https://account.hana.ondemand.com
Please follow the instructions given to you by the trainer in case there has been some last minute
change to the HCP location / account.
2.1 Logon to the SAP HANA Cloud Platform, start the SAP Web IDE and enable the
OData Model Editor
Explanation Screenshot
4
INT260
Explanation Screenshot
5
INT260
Explanation Screenshot
Las Vegas:
Please Note:
You will be automatically
Barcelona:
directed to the correct account
(int260us1 for Las Vegas and
int260emea for Barcelona).
8. Go to Subscriptions.
6
INT260
Explanation Screenshot
Las Vegas:
10. Click on the Application URL
to start the SAP Web IDE
7
INT260
Explanation Screenshot
Summary
You have prepared the SAP Web IDE development environment.
2.2 Develop the initial OData Model using the OData Model Editor
8
INT260
Explanation Screenshot
3. Provide
INT260_<yxx>_Folder as the
Folder Name and press OK.
9
INT260
Explanation Screenshot
5. Provide
INT260_<yxx>_Model as the
Model Name.
Use the drop-down box to
select 2.0 as the OData
Version.
10
INT260
Explanation Screenshot
9. Provide
Name="BusinessPartner"
10. Provide
Name=“BusinessPartnerID”
Type="Edm.String"
Nullable="false"
Name="BusinessPartnerID"
11
INT260
Explanation Screenshot
14. Provide
Name=“CompanyName”
Type="Edm.String"
Name="Address"
Name="AddressGUID"
Type="Edm.Guid"
Nullable="false"
12
INT260
Explanation Screenshot
21. Provide
Name="Assoc_BusinessPart
ner_Address"
Type="S1.BusinessPartner
"
Multiplicity="1"
Role="FromRole_Assoc_Bus
inessPartner_Address"
Type="S1.Address"
Multiplicity="1"
Role="ToRole_Assoc_Busin
essPartner_Address"
13
INT260
Explanation Screenshot
23. Provide
Name="ToAddress"
Relationship="S1.Assoc_B
usinessPartner_Address"
ToRole="ToRole_Assoc_Bus
inessPartner_Address"
FromRole="FromRole_Assoc
_BusinessPartner_Address
"
Name="BusinessPartnerSet"
EntityType="S1.BusinessPa
rtner"
Name="AddressSet"
EntityType=" S1.Address"
14
INT260
Explanation Screenshot
29. Provide
Name="AssocSet_BusinessP
artner_Address"
Association="S1.Assoc_Bu
sinessPartner_Address"
Role="FromRole_Assoc_Bus
inessPartner_Address"
EntitySet="BusinessPartn
erSet"
Role="ToRole_Assoc_Busin
essPartner_Address"
EntitySet="AddressSet"
15
INT260
Explanation Screenshot
16
INT260
Explanation Screenshot
17
INT260
Explanation Screenshot
Summary
You have now developed the initial OData Model using the OData Model Editor.
18
INT260
Overview
Estimated time: 30 minutes
Objective
The objective of this chapter is to create and provision an OData service based on the data model that
you developed in the previous chapter. The service will be built using the SAP Gateway Service
Builder.
Exercise Description
In this exercise you will:
Use the SAP Gateway Service Builder to create a new project
Import the OData EDMX file that you created in the exercise before
Provision the OData service using predefined CDS views
Generate, register and test the OData service using the Gateway Client
3.1 Create a SAP Gateway Service Builder project and perform the provisioning
using CDS views
Explanation Screenshot
User: INT260-<yxx>
Password: welcome
19
INT260
Explanation Screenshot
6. Provide
Project: ZINT260_<yxx>
Description: ZINT260_<yxx>
Service
Package: $TMP
20
INT260
Explanation Screenshot
21
INT260
Explanation Screenshot
22
INT260
Explanation Screenshot
16. Provide
23
INT260
Explanation Screenshot
19. Right-click on
BusinessPartnerSet and
choose Map to Data Source.
20. Provide
24
INT260
Explanation Screenshot
25
INT260
Explanation Screenshot
26
INT260
Explanation Screenshot
Summary
You have imported your data model into a Gateway Service Builder project and you have provisioned
the service with CDS view as the data source.
Additional Information:
Below you find the two CDS views that we’ve used in this exercise.
Definition of the CDS-view ZDDL_INT260_BUSINESSPARTNER:
@AbapCatalog.sqlViewName: 'ZCDS_INT260_BuPa'
@EndUserText.label: 'TechEd 2015 INT260 CDS-View BusinessPartner'
define view Zddl_Int260_Businesspartner
as select from snwd_bpa as partner
association [0..1]
to Zddl_Int260_Address as address
on partner.address_guid = address.AddressGUID
{
key partner.bp_id as BusinessPartnerID,
partner.company_name as CompanyName,
partner.email_address as EmailAddress,
partner.phone_number as PhoneNumber,
partner.web_address as WebAddress,
partner.legal_form as LegalForm,
partner.address_guid,
address
27
INT260
@AbapCatalog.sqlViewName: 'ZCDS_INT260_Adr'
@EndUserText.label: 'TechEd 2015 INT260 CDS-View Address'
define view Zddl_Int260_Address
as select from snwd_ad as address
{
key address.node_key as AddressGUID,
address.city as City,
address.postal_code as PostalCode,
address.street as Street,
address.building as Building,
address.country as Country
Tipp: There is a report (RUTDDLSSHOW) that allows you to display the definition of a CDS-view out
of the ABAP environment.
3.2 Register and Test the OData service using the Gateway client
Explanation Screenshot
28
INT260
Explanation Screenshot
29
INT260
Explanation Screenshot
8. Remove the ?$format=xml in
the URI and replace it with
BusinessPartnerSet so that
you execute the URI
/sap/opu/odata/SAP/ZINT26
0_<yxx>_SRV/BusinessPart
nerSet
/sap/opu/odata/SAP/ZINT26
0_<yxx>_SRV/BusinessPart
nerSet('0100000005')
30
INT260
Explanation Screenshot
12. Add the /ToAddress
navigation to the URI so that
you execute the URI
/sap/opu/odata/SAP/ZINT26
0_<yxx>_SRV/BusinessPart
nerSet('0100000005')/ToAdd
ress
Summary
You now have registered your OData service and executed it using the SAP Gateway Client.
3.3 (Optional) – Implement a default sorting for the Business Partner entity set
Explanation Screenshot
31
INT260
Explanation Screenshot
32
INT260
Explanation Screenshot
8. Navigate to INT260
Solutions Exercise 3.3
and open the file
BUSINESSPARTNERS_GET
_ENTITYSET.txt via double-
click.
33
INT260
Explanation Screenshot
11. Your
BUSINESSPARTNERS_GET
_ENTITYSET method should
now look like:
34
INT260
Explanation Screenshot
/sap/opu/odata/SAP/ZINT26
0_<yxx>_SRV/BusinessPart
nerSet
17. Add
?$orderby=BusinessPartner
ID to the URI so that you
execute the URI
/sap/opu/odata/SAP/ZINT26
0_<yxx>_SRV/BusinessPart
nerSet?$orderby=Business
PartnerID
Summary
You have added a redefinition for the BUSINESSPARTNERS_GET_ENTITYSET method in your data
provider extension class to implement a default sorting of the collection in case no paging and no
other sorting was requested.
35
INT260
Overview
Estimated time: 25 minutes
Objective
The objective of this chapter is to generate a Fiori-like application using the master/detail template in
the WebIDE. The application will be generated based on the OData service that you developed in the
previous chapter.
Exercise Description
In this exercise you will:
Create a Destination in the HANA Cloud Platform
Generate a Fiori-like application using the WebIDE master/detail template
Choose your OData service from the Gateway service catalog
Add a default sorting initiated by your SAPUI5 application
Add properties from the existing OData model to the application
4.1 Define an individual Destination in the SAP HANA Cloud Platform Cockpit.
Explanation Screenshot
Las Vegas:
36
INT260
Explanation Screenshot
3. Navigate to Destinations
5. Click on Desktop.
37
INT260
Explanation Screenshot
8. Go to Solutions Exercise
4.1.
User: INT260-<yxx>
Password: welcome
38
INT260
Explanation Screenshot
Summary
You have now created an own destination in the SAP HANA cloud platform cockpit. This destination
uses your individual user which we need for the upcoming exercises.
Explanation Screenshot
39
INT260
Explanation Screenshot
40
INT260
Explanation Screenshot
OData Collection:
BusinessPartnerSet
Item Title: CompanyName
Numeric Attribute: LegalForm
Units Attribute:
BusinessPartnerID
41
INT260
Explanation Screenshot
11. In the Detail Section provide
Business Partner as Title
and Business Partner
Details as Detail Text.
Attribute 1: PhoneNumber
Attribute 2: WebAddress
Attribute 3: EmailAddress
Attribute 1: Street
Attribute 2: PostalCode
Attribute 3: City
Summary
You have created a Fiori-like master/detail application using the OData service that you have
developed before.
42
INT260
Explanation Screenshot
43
INT260
Explanation Screenshot
44
INT260
Explanation Screenshot
45
INT260
Explanation Screenshot
Summary
You have run the generated application and verified that the data is accessed from the backend
system.
46
INT260
Explanation Screenshot
47
INT260
Explanation Screenshot
items="{/BusinessPartner
Set}">
items="{/BusinessPartner
Set}">
to
items="{path:'/BusinessP
artnerSet',
sorter:{path:'CompanyNam
e'}}">
48
INT260
Explanation Screenshot
Summary
You have now added a default sorting to the main list of the master view.
4.5 Add properties from the existing OData model to the application
Explanation Screenshot
2. Double-click on
Detail.view.xml to open the
view file of the detail view.
49
INT260
Explanation Screenshot
3. This opens up the xml
definition of the detail-view.
Scroll down to the second
IconTabFilter (the one with
id="iconTabFilter2")
where you find the properties
Street, PostalCode and
City.
50
INT260
Explanation Screenshot
Summary
You have now added two more properties of the Address entity type to the detail view of your WebIDE
project.
51
INT260
Overview
Estimated time: 25 minutes
Objective
The objective of this chapter is to make the Email Address editable in the application. For this you will
first need to enhance the OData service and then adjust the SAPUI5 application accordingly.
Exercise Description
In this exercise you will:
Enhance the OData service by mapping an update BAPI to the update operation of the
BusinessPartnerSet entity set.
Test the update operation using the Gateway client
Make the Email Address field editable in the SAPUI5 application
Add a save button to the application and trigger the corresponding update operation
Optionally analyze the error log and debug your OData service
Explanation Screenshot
52
INT260
Explanation Screenshot
COMPANY_NAME to
CompanyName
EMAIL_ADDRESS to
EmailAddress
PHONE_NUMBER to
PhoneNumber
WEB_ADDRESS to
WebAddress
LEGAL_FORM to LegalForm
53
INT260
Explanation Screenshot
54
INT260
Explanation Screenshot
COMPANY_NAME
EMAIL_ADDRESS
PHONE_NUMBER
WEB_ADDRESS
LEGAL_FORM
55
INT260
Explanation Screenshot
Summary
You have now enabled the update operation of the BusinessPartnerSet entity set by mapping the
corresponding update BAPI to the operation.
Explanation Screenshot
1. Open the Gateway Client and
execute a GET on URI
/sap/opu/odata/SAP/ZINT26
0_<yxx>_SRV/BusinessPart
nerSet('0100000032')
56
INT260
Explanation Screenshot
57
INT260
Explanation Screenshot
Summary
You have verified that the update operation of the BusinessPartnerSet entity set is working.
Explanation Screenshot
1. Switch to the WebIDE and
reload the page as the
session might have expired in
the meantime.
58
INT260
Explanation Screenshot
2. The Detail.view.xml file
should still be open. If not
open it via double-click.
<Input
id="inputEmailAddress"
value="{EmailAddress}"/>
<Button text="Save"
width="80px"
id="buttonSave"
press="onSaveButton"/>
59
INT260
Explanation Screenshot
60
INT260
Explanation Screenshot
jQuery.sap.require("sap.
m.MessageToast");
jQuery.sap.require("sap.m
.MessageBox");
61
INT260
Explanation Screenshot
Press OK.
Summary
You have made the Email Address field editable, including the update on the backend side.
62
INT260
Explanation Screenshot
/n/IWFND/ERROR_LOG
63
INT260
Explanation Screenshot
64
INT260
Explanation Screenshot
65
INT260
Explanation Screenshot
Summary
You have analyzed the error on the Gateway Hub as well as on the Backend side.
66
INT260
67
INT260
Overview
Estimated time: 20 minutes
Objective
The objective of this chapter is to add a table with the related sales order of the selected business
partner to the SAPUI5 application.
Exercise Description
In this exercise you will:
Add a new entity type + entity set containing the sales orders to the OData service
Add the required association and navigation property between the business partner and the
sales orders
Provision the query operation of the new sales order entity set
Add a new tab with a table to the SAPUI5 application
Fill the table based on the data provided via the new navigation property
Explanation Screenshot
68
INT260
Explanation Screenshot
69
INT260
Explanation Screenshot
7. In 1st step of the wizard
provide:
Association Name:
Assoc_BusinessPartner_Sa
lesOrders
Principal Entity
Entity Type Name:
BusinessPartner
Cardinality: 1
Navigation Property:
ToSalesOrders
Dependent Entity
Entity Type Name:
SalesOrder
Cardinality: 0..n
70
INT260
Explanation Screenshot
71
INT260
Explanation Screenshot
15. Drag&drop the parameter
BP_ID from the data source
tree on the right-hand side to
the Data Source Parameter
column of the newly added
line.
/sap/opu/odata/SAP/ZINT26
0_<yxx>_SRV/SalesOrderSe
t
/sap/opu/odata/SAP/ZINT26
0_<yxx>_SRV/BusinessPart
nerSet('0100000008')
72
INT260
Summary
You have now added a new entity type SalesOrder to your OData model / service and you have
provisioned it using a Remote Function Module. Finally you have tested the new collection using the
Gateway Client.
Explanation Screenshot
2. Right-click on Detail.view.xml
and choose Open With
Layout Editor.
73
INT260
Explanation Screenshot
74
INT260
Explanation Screenshot
Icon to sap-icon://table-view
Icon Color to Default
75
INT260
Explanation Screenshot
9. Scroll down to the end and
locate the line
<IconTabFilter text=""
count="" icon="sap-
icon://table-view"
iconColor="Default"
id="__filter0"/>
76
INT260
Explanation Screenshot
Navigate to a business
partner that has sales orders
associated (e.g. Asia High
Tech or DelBont Industries)
and click on the new tab to
see the list of sales orders.
Summary
You have added a new tab with the list of related sales orders to your application.
77
INT260
Overview
Estimated time: 20 minutes
Objective
The objective of this chapter is to add an analytical chart to the SAPUI5 application, visualizing data
provided by an ABAP Managed Database Procedure (AMDP).
Exercise Description
In this exercise you will:
Add a new entity type + entity set containing the chart data for the OData service
Provision the new entity set using an ABAP Managed Database Procedure
Add a new tab to the SAPUI5 application containing a ChartContainer showing the data from
the new entity set
Optionally launch the application from a smartphone / tablet device using a QR-code
Explanation Screenshot
2. Provide
Press Enter.
78
INT260
Explanation Screenshot
4. Create 4 properties by
pressing the create button.
Precision: 17
Scale: 3
Unit Property: CurrencyCode
79
INT260
Explanation Screenshot
8. In 1st step of the wizard
provide:
Association Name:
Assoc_BusinessPartner_Ch
artData
Principal Entity
Entity Type Name:
BusinessPartner
Cardinality: 1
Navigation Property:
ToChartData
Dependent Entity
Entity Type Name: ChartData
Cardinality: 0..n
80
INT260
Explanation Screenshot
81
INT260
Explanation Screenshot
/sap/opu/odata/SAP/ZINT26
0_<yxx>_SRV/BusinessPart
nerSet('0100000008')/ToCha
rtData
Summary
You have added a new entity type that provides the chart data for a given business partner. The chart
data is provided via an ABAP managed database procedure (AMDP).
82
INT260
Additional Information:
The definition of the AMDP ZCL_INT260_AMDP:
PUBLIC SECTION.
INTERFACES if_amdp_marker_hdb.
METHODS get_data
IMPORTING
VALUE(iv_bp_id) TYPE snwd_partner_id
EXPORTING
VALUE(et_result) TYPE tt_output.
ENDCLASS.
ENDMETHOD.
ENDCLASS.
7.2 Add another tab to the application showing the chart data
Explanation Screenshot
83
INT260
Explanation Screenshot
2. Double-click on the
Detail.view.xml file to open it.
3. Insert:
xmlns:suite="sap.suite.ui.com
mons"
xmlns:viz="sap.viz.ui5.control
s"
84
INT260
Explanation Screenshot
var aVizFrameIDs =
["vizFrameBar1"];
aVizFrameIDs.forEach(thi
s._setChartData.bind(thi
s));
85
INT260
Explanation Screenshot
var aVizFrameIDs =
["vizFrameBar1"];
aVizFrameIDs.forEach(this._r
esetChartData.bind(this));
Summary
You have added a new tab to the application showing the gross amount per product of all sales orders
associated to the selected business partner.
7.3 (Optional) – Launch the application on your smartphone using the QR code
Explanation Screenshot
86
INT260
Explanation Screenshot
Summary
You have accessed the QR-code of your application in the test environment.
87
INT260
88