47
8/11/2019 CD163.pdf http://slidepdf.com/reader/full/cd163pdf 1/47 Chaim Bendelac – HANA Architect Rafi Bryl – HANA Product Management TechEd 2013, Oct-Nov-Dec 2013 CD163 SAP HANA Native Applications River Based Development

CD163.pdf

Embed Size (px)

Citation preview

Page 1: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 1/47

Chaim Bendelac – HANA ArchitectRafi Bryl – HANA Product Management

TechEd 2013, Oct-Nov-Dec 2013

CD163 

SAP HANA Native Applications

River Based Development

Page 2: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 2/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Disclaimer

This presentation outlines our general product direction and should not be relied on

purchase decision. This presentation is not subject to your license agreement or anywith SAP. SAP has no obligation to pursue any course of business outlined in this pr

develop or release any functionality mentioned in this presentation. This presentatio

strategy and possible future developments are subject to change and may be chang

time for any reason without notice. This document is provided without a warranty of a

express or implied, including but not limited to, the implied warranties of merchantab

particular purpose, or non-infringement. SAP assumes no responsibility for errors or

document, except if such damages were caused by SAP intentionally or grossly neg

Page 3: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 3/47

Motivation

Page 4: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 4/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Native HANA application development

SAP HANA: a platform for native business applications

In-memory Database

 All data is represented and stored as efficient in-memory data-structures

Columnar access, Compression

Rich data types (graph, geo-space, multi-value, …) 

Designed for Performance

On-chip cache efficiencies (locality)

Parallel execution – hundreds of concurrent threads, cores

Planning, predictive analytics and business libraries

Built-in Application Services (XS)

Native Application development tools

HTTP and OData service interfaces

Page 5: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 5/47© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Creating an application

T1 T2T3

Page 6: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 6/47© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Creating an application

T1 T2T3

V1

V2

cv 

Page 7: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 7/47© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Creating an application

T1 T2T3

V1

V2

data

model

(DB)

cv 

sp 

trigger

Page 8: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 8/47© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Creating an application

T1 T2T3

V1

V2

data

model

(DB)

cv 

sp 

trigger

access control (RBAC)

Page 9: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 9/47© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Creating an application

T1 T2T3

V1

V2

data

model

(DB)

cv 

sp 

control

trigger

access control (RBAC)

business

logic (MVC)

Page 10: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 10/47© 2013 SAP AG or an SAP affiliate company. All rights reserved.

business

logic (MVC)

Creating an application

data model

T1 T2T3

V1

V2

data

model

(DB)

cv 

sp 

control

trigger

access control (RBAC)

SQL over xDBC

Page 11: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 11/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

business

logic (MVC)

Creating an application

data model

T1 T2T3

V1

V2

data

model

(DB)

cv 

sp 

control

view

trigger

access control (RBAC)

OData over HTTP

SQL over xDBC

Page 12: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 12/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

business

logic (MVC)

Creating an application

data model

T1 T2T3

V1

V2

data

model

(DB)

app

mob

app

cv 

sp 

control

view

trigger

UI

access control (RBAC)

OData over HTTP

SQL over xDBC

Page 13: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 13/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Creating an application, using River

T1 T2T3

V1

V2

data

model

(DB)

app

mob

app

cv 

sp 

control

trigger

UI

access control (RBAC)

business

logic

OData over HTTP

Page 14: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 14/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

River vision

Simplify the experience of developing

SAP HANA Native Applications 

River Language

River Programming Model

River Development Environments

Page 15: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 15/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

The River Language

Use River to create an integrated specification of the

data model

business logic

access control

River is familiar, declarative, object-oriented, and modular

River is cross-compiled into the most efficient HANA objects

HANA database objects (tables, roles…) 

Stored procedures (SQLScript, JavaScript) OData and XS access controls

Developers focus on intent and leave optimization

and runtime configuration to the tools ("timeless software")

a

c

Page 16: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 16/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

HANA XS development model 

1. Develop & Share

2.  Activate & Test

3. Deploy

activate

Activation

DB objects

SScript

OData

 Auth

XSJS

roles

River

compiler

p

studioRiver Editor

(on-premise)

browserRiver webEditor

(Cloud)

browser

Studio

Repository

.rdl

business app

developers

.rdl

workspace,

save

HANA based develop

Object management &

Delivery and patching

Page 17: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 17/47

The River Language(aka RDL)

Page 18: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 18/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Demo scenario: "River Airlines"

River Airlines reservation system

List all flights

Book a seat

… 

Implementation

Flight 

flight id, from/to,

list of seatsPassenger  

passenger details,

flight & seat reservation

Seat 

status

City

Page 19: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 19/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Entities and associations: the data model

entity Flight {

key flightId: String(8);

flightNum: String (3);

cityFrom: Association to City;

cityTo: Association to City;

depDate: LocalDate;depTime: LocalTime;

flightSeats: Association[0..*] to Seat via ba

}

entity Seat {

key flight: Association to Flight;

id: SeatNum;

isExitRow: Boolean default false;

Status: enum {free; reserved;};

}

Primitive types,

enumerations,

structured types

keys

Use "E/R modeling" to define your data model

 – Enti t ies  correspond to database tables – Associat ions  describe relations between tables

Page 20: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 20/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Views

entity Flight {

key flightId: String(8);

flightNum: String (3);cityFrom: Association to City;

cityTo: Association to City;

depDate: LocalDate;

depTime: LocalTime;

flightSeats: Association[0..*] to Seat via backlink flight;

}

view TodaysFlights as

select from Flight {flightNum, cityFrom, cityTo, depTime}

where depDate = today()

order by depTime ASC;

g

Page 21: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 21/47

Demo: Entities

Page 22: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 22/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Actions: the business logic

entity Seat {

flight: Association to Flight;

seatNum: SeatNum;

isExitRow: Boolean default false;

seatStatus: SeatStatus;

}entity Flight {

… 

flightSeats: Association[0..*] to Seat via backlink flight;

action GetEmptySeats() : Seat [] {

return select * from this.flightSeats

where Seat.seatStatus = SeatStatus.free;

}

}

this

 Actions describe the application's business logic

 – Local variables (scalar, streams) – Control statements (if, foreach, apply…) 

 – Integrated SQL queries

Page 23: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 23/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Extended queries

entity Seat {

flight: Association to Flight;

seatNum: SeatNum;

isExitRow: Boolean default false;

seatStatus: SeatStatus;

}entity Flight {

… 

flightSeats: Association[0..*] to Seat via backlink flight;

action GetEmptySeats() : Seat [] {

return select * from this.flightSeats

where Seat.Status = SeatStatus.free;

}

}

 – Use entity associations naturally in queries:

compare to SQL!

=  __temp16 = select T1. … from Flights as T0

inner   join "flights.Seat" as T1

on (T0."flightId" = "T0:flightSeats"."flight.flig

where "FlightId" = 12345;

 __retval__ = select T2. … from :__temp16 as T2 wh

 __FlightId St

FlightId Sea

id

Flight

temp16

Seat

Page 24: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 24/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Foreach

entity market {element company: String;element sales: Int;

}

// list all companies, sorted by accumulative market share 

let totalMarket = SELECT SUM (sales) FROM  market;

let accumulated = 0;

foreach (c in SELECT * FROM market ORDER BY sales DESC) {

accumulated = accumulated + c.sales;

outputMarketShare(c.company, accumulated / totalMarket);

}

IBM 

MS Oracle

 

.. 

Oracle 

IBM 

MS 

.. 

ma

Page 25: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 25/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Error handling

error InvalidPromotion {

empId : typeof Employee.id ;

current: Int;

target: Int;

}

entity Employee {

element grade: Int;

action promote(toGrade: Int) {

if (toGrade – this.grade > 3)

raise error InvalidPromotion {empId : this.id , current: this.grade, target: toGrade};

else

this.grade = toGrade;

}

onerror err: InvalidPromotion in promote(toGrade: Int) {

debug("Cannot promote from " + err.current + " to " + err.target);

return ErrorDecision.fail;

}

}

Page 26: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 26/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Access Control

role Dispatcher;

entity Flight {

key flightId: String(8);

flightNum: String (3);cityFrom: Association to City;

cityTo: Association to City;

depDate: LocalDate;

depTime: LocalTime;

flightSeats : Association[0..*] to Se

backlink flight;

}

action OpenNewFlight() accessible by Dispat

 }

entity Seat {

…… 

action save() accessible by Flight;

… 

Define ro les

CRUD and call access privileges  Assign run-time users to roles

Page 27: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 27/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Interoperability

entity employee {

action is_legal_SAP_email(hdr: String): Boolean as HANAJS {%

var re = /^\S+@sap.(com|corp)$/;

return re.test(v_hdr);

%}

}

entity Company as alias to sap.hana.catalog.ExtTable.T001;

view Company as SELECT FROM sap.hana.catalog.ExtTable.T001 {

BUKRS as companyCode, BUTXT as companyName

}

let StockQuotes: StockQuote[] = sap.hana.repository.XSStock.fetcher.getQuotes('http://www.nasdaq.com/quot

breakouts: inlineJavaScript or

SQLScript 

alias

abstraction view 

Call XS JS directly 

Page 28: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 28/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Customers Channel Suppliers Accounting ForeInventory Products Pricing Planning

Customer

Service

Risk Management

Team

Finance and

Operations

 Account

 Administration

Executive

Management

Suite on

HANA

Using HANA Live – SAP Business Suite virtual data mod

Page 29: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 29/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Using HANA Live – SAP Business Suite virtual data mod

Customer

Service

Risk Management

Team

Finance and

Operations

 Account

 Administration

Executive

Management

Customers Channel Suppliers Accounting ForeInventory Products Pricing Planning

VDM

Suite on

HANA

Page 30: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 30/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

HANA Live example: ERP sales financials

ListOfCreditBlockedSalesOrders

ListOfContracts

SalesOrderItem

VBAK

VBAPVBPA

Using River:

let badOrders =

SELECT * FROM sap.hba.crm.ListofCreditBlockedSalesO

Page 31: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 31/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Incremental Specification (Fragments)

namespace EPM  {entity PurchaseOrder {element note;element partner;

action accept();action reject(reason: String);… 

}… 

}

Declaration

namespace EPM  {entity PurchaseOrder {element note: LargeString;element partner: Association to

BusinessPartner;action accept() { … } action reject(reason: String) { … } … 

}… 

}

Definitionnamespace EPM  {entity PurchaseOrder {action accept()

accessible by AuthorizedApproval;… 

}role AuthorizedApproval { … } 

}

 Access

Controlentity EPM.PurchaseOrder {

action accept()@raises.errors: ‘InvalidModification’; 

onerror e: InvalidModification inaccept() { … }

}error EPM.InvalidModification { … } 

Error

Handling

namespace EPM  {entity PurchaseOrder {element note: LargeStringelement partner: Associat

action accept()accessible by [email protected]: ‘Invali

onerror e: InvalidModific

action reject(reason: Str

… }role AuthorizedApproval  {

error InvalidModification entity BusinessPartner {…}

}

Page 32: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 32/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Other RDL features

Built-in library functions (math, string …) 

Wrappers for HANA libraries (PAL, …) 

Store changing instructions (save, delete)

 Apply

Subtleties of assignments ("let")

Lie Cycle Management

Transaction Support

Streams!

… 

Page 33: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 33/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

mobile

OData

Open Data Protocol: a web protocol to query and

update data over HTTP, using JSON

River Entities and Actions are immediately  exposed as

OData structures upon activation

Read (with filter), write, update, delete, call … 

Control via Namespaces and export keyword

See further: http://www.odata.org Entity

Data

Model

HANA

Database

OData services

browsers client

Page 34: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 34/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

River integration with UI app builders

web-based IDE integration with SAP UI App builders

OData consumption

OData auto-documentation / generation

Generation of HTML "CRUD" templates

%

x

River

Page 35: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 35/47

Demo: Actions

Page 36: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 36/47

River Tools

W b b d d l t C l D l

Page 37: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 37/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Web-based development: Casual Developers

sign up…  deploy… develop… 

browser

test… 

HANA

C il ti E l

Page 38: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 38/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Compilation Example

application final_grade {

role admin;role student;

export @ODataentity EntA {

element name: String;element grade: Integer;action get_my_grade() : Integer accessible by student {

return grade;}

action create() accessible by admin;

}

action my_breakout(em : String) : Integer as HANAJS

{%return 1;

%}

view ViewA accessible by admin as SELECT * FROM EntA;

}

Database table… 

Database view…

roles… 

authorizations… 

SQLScript cod

XS JS code… 

OData

control

D d d E ti Pl

Page 39: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 39/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

namespace show.business {

entity Producer {key element name : String;element movies: Association[0..*] to Movie via backlink producer;

action createMovie(maxCost: DecimalFloat, actorsCost: Integer): Movie[0..*] {

let cheapWriter: ScriptWriter = SELECT ONE * FROM ScriptWriter ORDER BY salary DESC;let latestMovieYear = SELECT MAX(year) AS latest FROM cheapWriter.movies WHERE cost < maxCost;let cheapMoviesCount = SELECT COUNT(1) AS numOfMovies FROM cheapWriter.movies WHERE

year = latestMovieYear.latest AND cost <= maxCost;let latestMovie: Movie = Movie{};if (cheapMoviesCount.numOfMovies != 0)

latestMovie = SELECT ONE * FROM cheapWriter.movies WHEREyear = latestMovieYear.latest ORDER BY cost DESC;

else latestMovie = Movie {title: 'Scary Movie', numberInSeries: 8};

let maxIncomeAttributes = SELECT ONE genre as highIncomeGenre,

rating as highIncomeRating FROM Movie ORDER BY income DESC;let newMovie: Movie = Movie {title: latestMovie.title + ' Sequel', ... producer: this};newMovie.save();

let cheapActorsCount = SELECT COUNT(1) AS numOfActors FROM Actor WHERE totalIncome < actorsCost;if (cheapActorsCount.numOfActors >= 1) {

let cheapActor: Actor = SELECT ONE * FROM Actor WHEREtotalIncome < actorsCost ORDER BY totalIncome ASC;

let newCasting: Casting = Casting{movie: newMovie, star: cheapActor, salary: 5000};newCasting.save();return cheapWriter.movies;

} } } }

1

4

5

6

23

7

88

4

53

2

1

ScriptWriter Mov

Execution

Dependency and Execution Plan

Page 40: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 40/47

Demo: Integration

Page 41: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 41/47

In Summary

Why River?

Page 42: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 42/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Why River?

Simplicity, coherence, timelessness, interoperability

 – based on Entity-Relations, use a single language

for data modeling, business logic and access control

River compiler handles native code optimization

 – Write/extend native applications using modular,

declarative, object-oriented design principles

UI integration

 – Expose RDL entities and actions instantly via OData

Productivity, cloud

 – XS integrated development experience

Integrated application server

 – XS runtime environment

separate i

impleme

More About River

Page 43: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 43/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

More About River

River will be released in SAP HANA SPS7

To learn more, or to participate in the ongoing

beta program:

Contact one of the speakers

URL: TBD

Thank you!

Further Information

Page 44: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 44/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Further Information

SAP Education and Certification Opportunities

www.sap.com/education 

Watch SAP TechEd Online

www.sapteched.com/online 

SAP Public Web

scn.sap.comwww.sap.com 

SAP TechEd Virtual Hands-on Workshops and SAP Tech

Page 45: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 45/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

Continue your SAP TechEd education after the event!

SAP TechEd Virtual Hands-on Workshops

 Access hands-on workshops post-event

 Available January – March 2014

Complementary with your SAP TechEd registration

SAP TechEd Online

 Access replays of keynotes, Demo

LIVE interviews, select lecture ses

View content only available online

http://saptechedhandson.sap.com/  http://sapteched.com/o

Page 46: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 46/47

FeedbackPlease complete your session evaluation for CD163.

Thanks for attending this SAP TechEd s

© 2013 SAP AG or an SAP affiliate company All rights

Page 47: CD163.pdf

8/11/2019 CD163.pdf

http://slidepdf.com/reader/full/cd163pdf 47/47

© 2013 SAP AG or an SAP affiliate company. All rights reserved.

 © 2013 SAP AG or an SAP affiliate company. All rights

No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG.

The information contained herein may be changed without prior notice.

Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.

National product specifications may vary.

These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation

SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services

in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an

SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SA

other countries.

Please see http://www.sap.com/corporate-en/legal/copyright/index.epx#trademark for additional trademark information and notices.