28.01.2013 Views

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

9 Writing Server-Side JavaScript<br />

Applications<br />

<strong>SAP</strong> <strong>HANA</strong> Extended Application Services (<strong>SAP</strong> <strong>HANA</strong> XS) provide applications and application developers with<br />

access to the <strong>SAP</strong> <strong>HANA</strong> database using a consumption model that is exposed via HTTP.<br />

In addition to providing application-specific consumption models, <strong>SAP</strong> <strong>HANA</strong> XS also host system services that<br />

are part of the <strong>SAP</strong> <strong>HANA</strong> database, for example: search services and a built-in Web server that provides access<br />

to static content stored in the <strong>SAP</strong> <strong>HANA</strong> repository.<br />

The consumption model provided by <strong>SAP</strong> <strong>HANA</strong> XS focuses on server-side applications written in JavaScript. The<br />

server-side JavaScript applications can make use of a powerful set of specially developed API functions, for<br />

example, to enable access to the current request session or the database. This section describes how to write a<br />

server-side JavaScript application that enables you to expose data, for example, using a Web Browser or any<br />

other HTTP client.<br />

9.1 Data Access with JavaScript in <strong>SAP</strong> <strong>HANA</strong> XS<br />

In <strong>SAP</strong> <strong>HANA</strong> Extended Application Services, the persistence model (for example, tables, views and stored<br />

procedures) is mapped to the consumption model that is exposed via HTTP to clients - the applications you write<br />

to extract data from <strong>SAP</strong> <strong>HANA</strong>.<br />

You can map the persistence and consumption models in the following way:<br />

● Application-specific code<br />

Write code that runs in <strong>SAP</strong> <strong>HANA</strong> application services. Application-specific code (for example, server-side<br />

JavaScript) is used in <strong>SAP</strong> <strong>HANA</strong> application services to provide the consumption model for client<br />

applications.<br />

Applications running in <strong>SAP</strong> <strong>HANA</strong> XS enable you to accurately control the flow of data between the<br />

presentational layer, for example, in the Browser, and the data-processing layer in <strong>SAP</strong> <strong>HANA</strong> itself, where the<br />

calculations are performed, for example in SQL or SQLScript. If you develop and deploy a server-side JavaScript<br />

application running in <strong>SAP</strong> <strong>HANA</strong> XS, you can take advantage of the embedded access to <strong>SAP</strong> <strong>HANA</strong> that <strong>SAP</strong><br />

<strong>HANA</strong> XS provides; the embedded access greatly improves end-to-end performance.<br />

9.2 Writing JavaScript Code<br />

9.2.1 Server-Side JavaScript in <strong>SAP</strong> <strong>HANA</strong> XS<br />

<strong>SAP</strong> <strong>HANA</strong> application services (XS server) supports server-side application programming in JavaScript. The<br />

server-side application you develop can use a collection of JavaScript APIs to expose authorized data to client<br />

requests, for example, to be consumed by a client GUI such as a Web browser or any other HTTP client.<br />

212<br />

P U B L I C<br />

© 2012 <strong>SAP</strong> AG. All rights reserved.<br />

<strong>SAP</strong> <strong>HANA</strong> <strong>Developer</strong> <strong>Guide</strong><br />

Writing Server-Side JavaScript Applications

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!