Uploaded by jaimegallogarcia

openSAP ui51 Week2 All Slides

advertisement
Week 2 Unit 1: Using a Remote
Service with Aggregation Binding
Using a Remote Service with Aggregation Binding
Week 2 – Become a Data Binding Expert
Unit 2.1
Unit 2.2
Using a Remote
Service with
Aggregation Binding
Working with
Automatic
Expressions
Conversion
and Formatters with Data Types
Unit 2.3
Unit 2.4
Unit 2.5
Unit 2.6
Sorting,
Grouping,
and Filtering
Binding Contexts
with Element
Binding
Working
with OData
Services
Connect to an OData
service & create an
aggregation binding
Rest of this week:
Extend app and learn all about major
data binding features in SAPUI5
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Public
2
Using a Remote Service with Aggregation Binding
Scenario and tools (recap)
Cloud
Connector *
IDE
deploy
Web Server /
App Platform
data
Back-End
System
DB
Develop and Test
SAP Web IDE
Publish the App
SAP HANA
Cloud Platform
Store/Fetch Data
SAP Gateway
(EPM Services)
* Establishes secure tunnel between cloud and on-premise systems
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Public
3
Using a Remote Service with Aggregation Binding
OData model
DB
Controller
OData engine on
back-end system
Model
Updates using data
binding
View
(two-way or one-way)
 The model sends an initial request to the server to request data.
 The server interprets and processes the request and sends back the requested data to the model.
 This round trip takes place for every data request or change in the model.
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Public
4
Using a Remote Service with Aggregation Binding
Absolute and relative bindings
Absolute binding path
{
"company": {
"name": "Treefish Inc",
"info": {
"employees": "3"
},
"contacts": [
{
"name": "Barbara",
"phone": "873"
},
{
"name": "Gerry",
"phone": "734"
}
]
}
}
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
/company
Relative binding path
info/employees
contacts/0/name
phone
Absolute binding paths start with a slash;
relative binding paths start with a name token
and are resolved relative to the context of the
control that is bound.
Binding Path Syntax for JSON Models
Public
5
Using a Remote Service with Aggregation Binding
Binding types
{
"company": {
Property binding {/company/name}
"name": "Treefish Inc",
"info": {
"employees": "3"
},
"contacts": [
{
"name": "Barbara",
"phone": "873"
},
{
"name": "Gerry",
"phone": "734"
}
]
}
}
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Binding Types
Public
6
Using a Remote Service with Aggregation Binding
Model inheritance
 A model can be set globally on the
core (not recommended), the
component, a view, or single
controls
 If you configure a model in the app
descriptor, it will be set on the
component level
manifest.json
model inheritance
 All children in this hierarchy will
automatically inherit the model of
their respective parent
SAPUI5 Core
Component
View
Controls
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Public
7
Thank you
Contact information:
open@sap.com
© 2016 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://global12.sap.com/corporate-en/legal/copyright/index.epx for additional trademark information and notices.
Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind, and SAP SE or its
affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP SE or SAP affiliate company 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.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related presentation, or to develop
or release any functionality mentioned therein. This document, or any related presentation, and SAP SE’s or its affiliated companies’ strategy and possible future
developments, products, and/or platform directions and functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time
for any reason without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. All forwardlooking statements are subject to various risks and uncertainties that could cause actual results to differ materially from expectations. Readers are cautioned not to place
undue reliance on these forward-looking statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions.
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Public
9
Week 2 Unit 2: Working with
Expressions and Formatters
Working with Expressions and Formatters
Binding syntax (recap)
1. Simple Property Binding
property="{/modelProperty}"
2. Complex Binding
property="{/modelPropertyA} {/modelPropertyB}"
3. Binding with Multiple Parts (Documentation):
property="{
parts: [
{ path: 'modelPropertyA'},
{ path: 'modelPropertyB'}
],
formatter : 'formatter.function‚
}"
4. Expression Binding (Documentation):
property="{= ${modelProperty} === 'someValue' ? 'statusA' : 'statusB'}"
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Public
2
Thank you
Contact information:
open@sap.com
© 2016 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://global12.sap.com/corporate-en/legal/copyright/index.epx for additional trademark information and notices.
Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind, and SAP SE or its
affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP SE or SAP affiliate company 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.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related presentation, or to develop
or release any functionality mentioned therein. This document, or any related presentation, and SAP SE's or its affiliated companies' strategy and possible future
developments, products, and/or platform directions and functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time
for any reason without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. All forwardlooking statements are subject to various risks and uncertainties that could cause actual results to differ materially from expectations. Readers are cautioned not to place
undue reliance on these forward-looking statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions.
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Public
4
Week 2 Unit 3: Automatic
Conversion with Data Types
Automatic Conversion with Data Types
Primitive types
SAPUI5 delivers the following primitive types out-of-the-box:
 sap.ui.model.type.Boolean
 sap.ui.model.type.Float
 sap.ui.model.type.Currency
 sap.ui.model.type.Integer
 sap.ui.model.type.Date
 sap.ui.model.type.String
 sap.ui.model.type.DateTime
 sap.ui.model.type.Time
 sap.ui.model.type.FileSize
You can create your own data types by extending one of the existing types.
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Public
2
Automatic Conversion with Data Types
Data type process
 Data typing allows you to format data for the UI while keeping actual data format in the model untouched.
 Bound properties with a defined type will automatically be formatted when displayed on the UI. Input
values in UI controls are parsed and converted back to the model type.
Format
01.05.2015
01-05-2015
Validate
SAPUI5 MODEL FORMAT
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
DISPLAY FORMAT
Public
3
Thank you
Contact information:
open@sap.com
© 2016 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://global12.sap.com/corporate-en/legal/copyright/index.epx for additional trademark information and notices.
Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind, and SAP SE or its
affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP SE or SAP affiliate company 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.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related presentation, or to develop
or release any functionality mentioned therein. This document, or any related presentation, and SAP SE’s or its affiliated companies’ strategy and possible future
developments, products, and/or platform directions and functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time
for any reason without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. All forwardlooking statements are subject to various risks and uncertainties that could cause actual results to differ materially from expectations. Readers are cautioned not to place
undue reliance on these forward-looking statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions.
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Public
5
Week 2 Unit 4: Sorting,
Grouping, and Filtering
Sorting, Grouping, and Filtering
Filtering
Filters are applied to the binding independent
of the model type.
You can use filters to make
your data searchable
View
Filter
Filter
Filter
applied to
Binding
Model
sap.ui.model.Filter API Documentation
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Public
2
Sorting, Grouping, and Filtering
Sorting and grouping
You can use sorters with grouping
to make your lists well-arranged
Sorters define the order and arrangement
of the items in an aggregation.
View
Sorter
Filter
Filter
applied to
Grouping
Function
(optional)
Binding
Model
sap.ui.model.Sorter API Documentation
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Sort and Group
by Category
Public
3
Thank you
Contact information:
open@sap.com
© 2016 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://global12.sap.com/corporate-en/legal/copyright/index.epx for additional trademark information and notices.
Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind, and SAP SE or its
affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP SE or SAP affiliate company 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.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related presentation, or to develop
or release any functionality mentioned therein. This document, or any related presentation, and SAP SE’s or its affiliated companies’ strategy and possible future
developments, products, and/or platform directions and functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time
for any reason without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. All forwardlooking statements are subject to various risks and uncertainties that could cause actual results to differ materially from expectations. Readers are cautioned not to place
undue reliance on these forward-looking statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions.
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Public
5
Week 2 Unit 5: Binding
Contexts with Element Binding
Binding Contexts with Element Binding
Binding types (recap)
 Property binding
allows properties of the control to be automatically
initialized and updated from model data.
 Aggregation binding
can be used to automatically create child controls
according to model data. This can be done either
by cloning a template control or by using a factory
function.
 Element binding
allows you to bind elements to a specific object in
the model data, which will create a binding context
and allow relative binding within the control and all
of its children.
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Public
2
Binding Contexts with Element Binding
Binding types (recap)
{
"company": {
"name": "Treefish Inc",
"info": {
"employees": "3"
},
"contacts": [
Aggregation binding {/company/contacts}
{
"name": "Barbara",
"phone": "873"
},
{
"name": "Gerry",
Element binding {/company/contacts/1}
"phone": "734"
}
]
}
}
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Binding Types
Property binding: {phone}
Property binding: {name}
Public
3
Binding Contexts with Element Binding
Element binding & relative property binding
updateElement: function(index) {
oPanel.bindElement(“/company/contacts/” + index);
JS
You can “rebind” the parent control to a different context by using the bindElement(path) method
}
this.updateElement("0");
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
this.updateElement("1");
Public
4
Thank you
Contact information:
open@sap.com
© 2016 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://global12.sap.com/corporate-en/legal/copyright/index.epx for additional trademark information and notices.
Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind, and SAP SE or its
affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP SE or SAP affiliate company 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.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related presentation, or to develop
or release any functionality mentioned therein. This document, or any related presentation, and SAP SE’s or its affiliated companies’ strategy and possible future
developments, products, and/or platform directions and functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time
for any reason without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. All forwardlooking statements are subject to various risks and uncertainties that could cause actual results to differ materially from expectations. Readers are cautioned not to place
undue reliance on these forward-looking statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions.
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Public
6
Week 2 Unit 6:
Working with OData Services
Working with OData Services
OData – Open Data Protocol
An open protocol to allow the creation and
consumption of queryable and interoperable
RESTful APIs
 Enables provision of data services based on
REST principles
 Contains a complete description of the feeds,
types, properties, and relationships exposed
by the service in EDM (service metadata)
 Defines data formats representing resources
like collections, entries, and properties
Documentation at odata.org
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Public
2
Working with OData Services
Entity types and OData types
Entity Type
Key
Property
Navigation
Property
OData Type
<EntityType Name=“Product" sap:content-version="1">
<Key>
<PropertyRef Name=“ProductID"/>
</Key>
<Property Name=“Name" Type="Edm.String" Nullable="false" MaxLength="80"
sap:label="Product Name" sap:creatable="false" sap:filterable="false"/>
<Property Name=“Description" Type="Edm.String" Nullable="false" MaxLength="12"
sap:label="Prod.Descrip." sap:creatable="false" sap:filterable="false"/>
<Property Name="Price" Type="Edm.String" Nullable="false" MaxLength="40"
sap:label="Price" sap:creatable="false" sap:filterable="false"/>
<Property Name="WeightMeasure" Type="Edm.String" Nullable="false" MaxLength="40"
sap:label="WeightMeasure name" sap:creatable="false" sap:filterable="false"/>
<NavigationProperty Name=“ToSupplier" Relationship="/IWBEP/GWSAMPLE_BASIC.
Assoc_BusinessPartner_Products"
FromRole="ToRole_Assoc_BusinessPartner_Products"
ToRole="FromRole_Assoc_BusinessPartner_Products"/>
Annotations
</EntityType>
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Public
3
Working with OData Services
URI structure and data access and query options
OData
URI
Results
Service
Document
<service_root_url>
Collection of entity sets, e.g. a list of available
tables in a service
EDMX
/$metadata
Definitions of the schema, like entity type,
property type, associations, navigations
Entity Set
/<entityset>
All entities of an entity set, e.g. all rows of a table
Entity
/<entityset>(<key>=<value>,<key>=<value>)
Entity of an entity set, based on key fields
Property
/<entityset>(<key>=<value>,<key>=<value>)/<property>
Property of the entity, e.g. a field of a row
 The content of an OData service can be accessed directly in the browser
 You can browse entities, entity sets, and properties via URI
GWSAMPLE_BASIC service on system ES4 (requires login)
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Public
4
Working with OData Services
OData simple query language
https://sapes4.sapdevcenter.com/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/Entity?<query parameters>
Service Root URI
 The names of all query
string parameters
defined by OData are
prefixed with a $
character
Resource path
Query options
Operation
Query Option
SQL Equivalent
Out-of-the-Box Support
Filtering
$filter
Where clause
Aggregation filter
Projecting
$select
Field selection
On demand usage
Sorting
$orderby
Sort
Aggregation sort
Paging
$top
Up to .. rows
sap.m.List growing
$skip
-
sap.m.List growing
Inlining
$expand
Innerjoin
On demand usage
Count
$count
Count(..)
Aggregation binding
$inlinecount
-
On demand usage
List of (most important) Query options: http://www.odata.org/developers/protocols/uri-conventions#QueryStringOptions
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Public
5
Working with OData Services
OData debugging tool for SAP NetWeaver OData services
 URL parameter:
sap-ds-debug=true
 Can be used to analyze and
explore your service
 Provides additional
information on queries,
performance, and the back
end itself
ProductSet entity on
GWSAMPLE_BASIC
(requires login)
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Public
6
Thank you
Contact information:
open@sap.com
© 2016 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://global12.sap.com/corporate-en/legal/copyright/index.epx for additional trademark information and notices.
Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind, and SAP SE or its
affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP SE or SAP affiliate company 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.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related presentation, or to develop
or release any functionality mentioned therein. This document, or any related presentation, and SAP SE’s or its affiliated companies’ strategy and possible future
developments, products, and/or platform directions and functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time
for any reason without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. All forwardlooking statements are subject to various risks and uncertainties that could cause actual results to differ materially from expectations. Readers are cautioned not to place
undue reliance on these forward-looking statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions.
© 2016 SAP SE or an SAP affiliate company. All rights reserved.
Public
8
Download