More Related Content Similar to Overview and Walkthrough of the Application Programming Model with SAP Cloud Platform (20) More from SAP Cloud Platform (20) Overview and Walkthrough of the Application Programming Model with SAP Cloud Platform2. 2PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Take the session survey.
We want to hear from you!
Be sure to complete the session evaluation
on the SAPTechEd mobile app.
Download the app from
iPhone App Store or Google Play.
CNA221
CNA221
3. ✓
✓
Please complete your
feedback for session
CNA221
Access replays at:
http://sapteched.com/online
Continue your discussions in:
sap.com/community
See all…
SAPTechEd blog posts
SAP TechEd
2018
4. 6PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Introduction
SAP
Web IDE
CDS
Service
SDKs
REST
OData
FioriHANA
Java EE,
Spring
Node.js
express
Eclipse
VSCode
CLI
The “Application Programming Model for SAP Cloud Platform” is a
framework of tools, languages and libraries by SAP and OSS to
efficiently and rapidly build enterprise services and applications in a
full-stack development approach.
It guides developers along a golden path of best practices, allowing
them to focus on their domain while relieving them from tedious
technical tasks.
5. 7PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Overview
We complement cloud-native technologies with…
a CDS-based Services framework
with 1st-class support by and for…
SAP Web IDE w/ tailored tools
SAP Fiori
SAP HANA
S/4 Extension scenarios
Resulting in…
A consistent end-to-end programming model for
enterprise services & applications
Guidance and best practices leveraging proven
SAP technologies + Open Source software
WebIDE
Infrastructure
App UIs?
Domain Logic?
Domain Model?
localWebIDE+local
SAP Fiori + other
SAP HANA + other
Service SDKsCDS
CDS
planned:
CDS
PlatformServices
6. 8PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Setup
Develop TestRun
CI/CD
Operate
Data
Services
Consumers
Context and our focus
Databases
SAP HANA
API Management
Monitoring
Scaling
Profiling
Connectivity
Big Data
Identities
Authentication
CI/CD
Destinations
Provisioning
Caching
Frontends / UIs
Your Services
and Apps
by S/4 HANA Cloud SDK, …
8. 10PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Fictional task given
Extension on
Cloud PlatformAdd Reviews
Manage
Orders
Maintain
Catalog
Admins
Browse Books
anybody
Order Books
registered
includes…
login…
includes…
T/5 backend system
In cloud first… T/5 later
Reuse
Service
9. 11PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Capture Intent on Conceptual Level
Best Practices & Benefits…
using { Country, managed }
from '@sap/cds/common‘;
service ProductService {
entity Products : managed {
key ID : UUID;
title : localized String;
descr : localized String;
country : Country;
}
}
» What, not How. «
10. 12PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Minimizing Boilerplate
service ProductService {
entity Products {
key ID : UUID;
title : localized String;
descr : localized String;
country : Country;
createdAt : DateTime @cds.on.insert: $now;
createdBy : User @cds.on.insert: $user;
modifiedBy : User @cds.on.update: $user;
modifiedAt : DateTime @cds.on.update: $now;
localized : Association to Products_texts
on localized.lang = $user.locale
and localized.ID = ID;
texts : Association to many Products_texts
on texts.ID=ID;
}
entity Products_texts {
key lang : Language;
key ID : UUID;
title : String;
descr : String;
}
type User : String(111);
type CountryCode : String(3);
type Locale : String(5);
//...
type Country : Association to Countries;
type Language : Association to Languages;
entity Countries : CodeList{
key code: CountryCode;
}
entity Languages : CodeList{
key code: Locale;
}
abstract entity CodeList {
name : localized String;
descr : localized String;
}
annotate Country with @(
title:'{i18n>Country}',
Common.ValueList.entity: 'Languages'
);
annotate Language with @(
title:'{i18n>Language}',
Common.ValueList.entity: 'Countries'
);
annotate CodeList with @(
UI.Identification: [{
$Type: 'UI.DataField', Value: name
}],
);
}
using { Country, managed }
from '@sap/cds/common‘;
service ProductService {
entity Products : managed {
key ID : UUID;
title : localized String;
descr : localized String;
country : Country;
}
}
» What, not How. «
11. 13PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Capture Intent on Conceptual Level
Best Practices & Benefits…
» What, not How. «
It’s not just about less to type…
It’s much more about:
Conciseness and comprehensiveness
Detecting flaws early
Single points to fix
Single points to optimize
Refocusing on your domain
i.e. about improving overall quality,
robustness and adaptability.
12. 14PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Capture Intent on Conceptual Level
Best Practices & Benefits…
Accelerate your Projects
» Run early «
» Grow as you go «
Getting Started
—————————————
o Setup your env (once)
o Start a Project
o Define Services Run
Add UIs / Frontends
——————————————
o Switch to Web IDE, and…
o Add a Fiori app Run
o Add Fiori markup Run
Provide Services
——————————————
o Derive Data Models Run
o Deploy to DBs Run
o Add Initial Data Run
o … 2b continued…
Close Feedback Loop
• Start with services top-down
• Spin-off parallel workstreams (→ frontend / backend)
• Using the Service Definitions as their contracts
13. 15PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Capture Intent on Conceptual Level
Best Practices & Benefits…
Accelerate your Projects
Leverage proven Methods
» We eat your dog food «
… originate close
to use cases
… are pushed down
to data sources
for execution
Database
CDS-based
Runtimes
Data
Models
Service
Defs.
Fiori UIs
Fiori
Markup
OData
CQLas views on
Queries
• OData = REST + Querying
• SAP Fiori = flexible generic UIs
• CDS += View Building
14. 16PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
RESTful ABAP
Common Programming Model
SAP Fiori / UI5
SAP HANA
SQL
OData, REST
ABAP
Frameworks
ABAP
Toolset
Core Data
Services
SAP Gateway
Extension
Services
Events
Models
Replication
Interoperability
Reuse of Skills
Cloud App Prog Model
SAP Fiori / UI5
SAP HANA / other
SQL
OData, REST
Java / Node
Frameworks
S/4 HANA
Cloud SDK
Core Data
Services
REST + OData libraries
» Our dog food @ SAP «
15. 17PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Capture Intent on Conceptual Level
Best Practices & Benefits…
Accelerate your Projects
Leverage proven Methods
Openness & Flexibility
Cloud Foundry
Kubernetes
XSA
local
SAP Fiori Angular React Vue • • •
SAP HANA PostgreSQL sqlite • • •
SAP Web IDE
Eclipse
VSCode
• • •
Core
Node.js Java
Core Data Services
• We focus on the Core of Data-oriented Services
• We integrate recommended choices from periphery …
• But without lock-in! still you decide what you use
16. 18PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Capture Intent on Conceptual Level
Best Practices & Benefits…
Accelerate your Projects
Leverage proven Methods
Openness & Flexibility
Web IDE provides tailored tools for the
application programming model.
You can use Web IDE and/or local tools of
your choice and switch between both.
Common Project Layout & Build
• app
• srv
• db
Local Development
• Command-line Tools
• known IDEs / Editors
• w/ CDS Editors
• Local test runs
• Maven/npm-based
automation
• • •
SAP Web IDE Full-Stack
• Project Storyboard
• Project Explorer
• Database Explorer
• Graphical Modeling
• Service Discovery
• Fiori Dev Tools
• CDS Editors
• Drag & Drop
17. 19PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
SAPWeb IDE Full-Stack tailored tools
Project Storyboard
Project Explorer
Database Explorer
CDS Editors
Outline
Drag & Drop
Problems View
Graphical Editors
Service Discovery and
integration wizards (e.g. S/4)
Fiori Development Toolset
18. 20PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Capture Intent on Conceptual Level
Best Practices & Benefits…
Accelerate your Projects
Leverage proven Methods
Openness & Flexibility
Enterprise Qualities
Intrinsic Enterprise Features & Qualities
Localized Metadata e.g. labels
Localized Data text tables
o Temporal Data valid from/to, time travel
Authorization
Audit Logging
Project-level Extensibility ( providers)
o Tenant-level Extensibility ( clients)
o GDPR support
o Validation Framework
o Declarative Constraints
o TypeScript for implementors
o …
19. 21PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Capture Intent on Conceptual Level
Best Practices & Benefits…
Accelerate your Projects
Leverage proven Methods
Openness & Flexibility
Enterprise Qualities
Cloud Qualities
Intrinsic Cloud Integration & Qualities
Authentication / UAA
JWT token handling
Configuration (via VCAP services, …)
Health checks
Logging & Monitoring
Tenant on/off boarding
Tenant isolation
o Rate limiting
o Caching (via Hystrix, …)
o Messaging (via RapidMQ, …)
o Resilience (in S/4H CloudSDK)
o …
by S/4 HANA Cloud SDK
23. 25PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Entities & Views (from SQL)
Associations
Annotations
Aspects
Concise Queries
entity Books @(title:‘Bücher‘) {
key ID : UUID;
title : localized String;
author : Association to Authors;
}
entity Authors {
key ID : UUID;
name : String;
books : Composition of many Books;
}
entity BooksList as select from Books {
ID, title, author.name as author
}
Entity-Relationship Modeling
Reflexive View Building borrowed from SQL
CDS is about…
24. 26PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Entities & Views (from SQL)
Associations
Annotations
Aspects
Concise Queries
// Pure, unpolluted Structure
define entity Foo { bar : String; }
// Fiori UI Markup
annotate Foo with @UI.Label:'Foo‘;
// Authorization Model
annotate Foo with @requires:‘admin‘;
// Customer-specific Extensions
extend entity Foo with {
car:{ wheels: Integer; }
}
separate concerns into partial definitions
avoids polluting your structure
allows using different tools on same effective models
in same or different files up to different projects
CDS is about…
25. 27PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
SELECT from Employees {
name, addresses [kind='business’] .city.{
name, country.name
}
}
Path Expressions w/ optional Infix Filters
(Nested) Postfix Projections
Permeable for native database features
SELECT e.name, city.name, country.name from Employees e
LEFT JOIN Addresses a on a.id = e.address_id and a.kind='business'
LEFT JOIN Cities city on city.id = addresses.city_id
LEFT JOIN Countries country on country.id = city.country_id
Entities & Views (from SQL)
Associations
Annotations
Aspects
Concise Queries
CDS is about…
26. 28PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Entities & Views (from SQL)
Associations
Annotations
Aspects
Concise Queries
service CatalogService {
entity Books as projection on my.Books;
entity Authors as projection on my.Authors;
entity Orders as projection on my.Orders {
*, book.title, book.author.name as author
} where createdBy = $user;
action cancel(order:UUID);
}
data-centric: entities with intrinsic CRUD ops
entities as views on underlying ones
with seamless mapping to REST + OData
CDS is about…
Service Definitions
27. 29PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Entities & Views (from SQL)
Associations
Annotations
Aspects
Concise Queries
Core Schema Notation (CSN) as the core of all:
models are plain JavaScript/JSON objects
minimal footprint, dynamic, no repositories
fast innovation and delivery cycles
zero lock-in to any database or stack
{ CSN }
CDS
YAML
OData
JSON, YAML
JPA
process
Open API
Code
SQL DDL
HANA DDL
JSON
CDS is about…
Litew8 reincarnation in Node.js
Service Definitions
let model = {Foo:{kind:'entity'}}
29. 31PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Implementing Services
Place a <service>.js file next to your <service>.cds file1 Add a Service Implementation Function2
Register your Event Handlers
.before → before generic ones
.on → instead of generic ones
.after → before results go out
3
+
Only for your real, domain-specific custom
logic, leaving the rest to the built-in generic
handlers
Note:
• all non-blocking, running in parallel
• all connection handling, transaction mgmt.,
etc. is taken care of by the fwk
30. 32PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Consuming Services
API Hub
cds importImport Service Definition
in case of external ones
1
Data Source
Database Data Model
Local Service
Service
Definition
External Service
Service
Definition
// query-style
SELECT.from (Foo) .where ({ID:111}) .then (foo => … )
let foo = await SELECT.from (Foo) .where ({ID:111})
// method call-style
ds.read(Foo) .where ({ID:111}) .then (foo => … )
// using declared custom operations
ds.getFoo (111) .then (foo => … )
Data Sources can be Databases, external Services or
local Services and are all consumed in the same way.
OData and cds.services support querying by default.
Connect to Data Source2
Read/Write Data3
const ds = await cds.connect.to ('SomeDataSource‘)
const { Foo } = ds.entities()
31. 33PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Service-level Mashups
CDS allows to easily mashup imported
definitions with local ones.
Views define which subset of data we are
interested in.
Imported
Service
Definition
API Hub
cds import
Import the Service Definition1
Local Service
Definitions
using ExternalService as ext from ‚./imported/service‘;
service CatalogService {
// served from local database
entity Books as projection on bookshop.Books;
entity Authors as projection on bookshop.Authors;
// served from external service
entity Orders as SELECT from ext.Orders {
*, book.title, book.author.name as author
} where createdBy = $user;
}
const ext = await cds.connect.to ('ExternalService')
const { Orders } = ext.entities()
cds.serve ('CatalogService').with (function(){
this.on ('READ', 'Orders', ()=> SELECT.from (Orders) … )
})
Mashup into Local Service Definition:2
Call out to the external service in a custom handler:3
32. 34PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Service-level Replication
using ExternalService as ext from '@imported/service‘;
entity Books {…}
entity Authors {…}
// local replica entity filled from external service
entity Orders as SELECT from ext.Orders {
*, book.title, book.author.name as author
} where createdBy = $user;
const { Orders } = cds.entities // local
cds.subscribe.to ('ExternalService‘) .with (ext => {
ext.on (['CREATED', 'UPDATED'], 'Orders‘, ({data:{IDs}}) => {
ext.read ('Orders') .where ('ID in', IDs) .foreach (
each => UPSERT(each).into (Orders)
)
})
})
Local Data
Model
Imported
Service
Definition
API Hub
cds import
Import the Service Definition1
Mashup into Local Data Model:2
Replicate actual data upon change events from the source:3
Cache data locally which is required in
frequent and close access.
Create tables with the views’ signature.
33. 35PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Open, Non-intrusive Design — you stay in control
We use established OSS de-facto standards
We add components focused on enterprise features
You stay in control, you choose what to use and when!
… e.g. in a custom server.js:
Node.js
express.js, …
cds.services
cds.ql, …
Java
Servlets, Spring
Service SDK
JDBC, JPA, cds.ql
34. 36PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Capture Intent on Conceptual Level
Best Practices & Benefits…
Accelerate your Projects
Leverage proven Methods
Openness & Flexibility
Enterprise Qualities
Cloud Qualities
Services, not BObjects
Data Model
Service A Service B
Services are stateless API facades.
They contain all logic and validations and
frequently expose views on data.
Data Models define passive
objects, mostly normalized and
managed in databases
35. 37PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Single-purposed Services
Manage
Orders
Maintain
Catalog
Admins
service CatalogService {
expose entity Books @readonly;
expose entity Authors @readonly;
action order (book) @requires:$user;
}
service CustomersService @(requires:$user) {
expose entity Orders @(restrict:[
{grant:'READ,DELETE', where:'buyer=$user‘}
]);
}
service AdminService @(requires:‘admin‘) {
expose entity Books
expose entity Authors;
expose entity Orders;
}
fosters focused and efficient implementations
enables ‘late-cut µ services’
Browse Books
anybody
Order Books
registered
login
includes…
36. 38PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Capture Intent on Conceptual Level
Best Practices & Benefits…
Accelerate your Projects
Leverage proven Methods
Openness & Flexibility
Enterprise Qualities
Cloud Qualities
Services, not BObjects
Querying, not ORM
ORMs provide…?
• Active objects manipulating internal state
• Abstraction, shielding me from SQL
• Portability across databases
• Eager/Lazy Loading
• Object Caches
• …?
37. 39PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Data Access with cds.ql
Managed Data Sources w/ CDS-based Reflection
Queries as 1st class objects
SQL-style usage
Object-style usage
Reflexive Querying w/ Late Materialization
Asynchronous, non-blocking execution
Managed Units of Work
39. 41PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Data
Services
Data
Models
Service
Defs.
Custom
Handlers
Fiori UIs
Fiori
Markup
OData
Stored
Procs
Breakouts
Summary — Core Programming Model
CDS
cds.services
cds.ql
We promote…
• Best Practices, not Anarchy!
• Openness, not Blackbox!
• Services, not Objects!
• Querying, not ORM!
• Capturing Intent
• Enterprise & Cloud Qualities
40. 42PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Cookbook — there’s more…
Getting Started
—————————————
o Setup your env (once)
o Start a Project
o Define Services Run
Add UIs / Frontends
——————————————
o Switch to Web IDE, and…
o Add a Fiori app Run
o Add Fiori markup Run
Provide Services
——————————————
o Derive Data Models Run
o Deploy to DBs Run
o Add Initial Data Run
o Add Custom Logic Run
o Reading / Writing Data
o Add Authorization, I18n, …
Reuse & Modularize
—————————————
o Reuse @sap/cds/common
o Reuse other packages
o Modularize your app
Consume Services
—————————————
o Import ext. Service APIs
o Consume Services
o Service-level Mashups
o Service-level Replication
o Serve required Interfaces
Deploy
——————————
o Deploy to Cloud
o Serverless
o … for own use
o … as SaaS solution
Customize
——————————
o Verticalization
o Tenant-level
Customization✓
✓
✓
✓
✓
41. 43PUBLIC© 2018 SAP SE or an SAP affiliate company. All rights reserved. ǀ
Status Quo / Outlook
o SAP Analytics Cloud integration
o Analytical List Page by Fiori
o Serverless deployment
o Reactive Java
o Enhanced GDPR support
o Validation Framework
o Declarative Constraints
o TypeScript for implementors
o …
CDS-based Service and Data Model
Service Providers in Node.js / Java
1st class support for HANA DBaaS
1st class support for Fiori Uis
1st class support in Web IDE
Local dev in VSCode, Eclipse, …
Fastrack dev with node + sqlite db
Intrinsic Enterprise Qualities, e.g…
Localized Data + I18n
Authorization
Audit Logging
GDPR support (basic)
Service Consumption via S/4H SDK
Service-level Mashups & Replication
Project-level Extensibility
Deployment to Cloud Foundry
o Basis for Serverless eBaaS
o 1st class support for PostgreSQL, …
o Fiori Draft support +
o OData v4
o Advanced support for Spring
o SaaS Tenant-level Extensibility
o More Tailored Tools Web IDE
o Temporal Data
o Events Consumption & Emitting
o Generic Service Consumption
o Generic support for Messaging
o Deploy to Kubernetes
available o in progress o planned
44. ✓
✓
Please complete your
feedback for session
CNA221
Access replays at:
http://sapteched.com/online
Continue your discussions in:
sap.com/community
See all…
SAPTechEd blog posts
SAP TechEd
2018