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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Use the $.import function, as follows:<br />

$.import("","greetLib");<br />

var greeting = $.path.to.your.library.filename.greet("World");<br />

$.response.setBody(greeting);<br />

2. Save and activate the changes to the JavaScript file.<br />

Although the operation is simple, bear in mind the following points:<br />

○ Additional objects in the package hierarchy<br />

The import operation generates a hierarchy of objects below $ that resemble the library's location in the<br />

repository, for example, for the library path/to/your/library/greetLib.xsjslib, you would see<br />

the following additional object:<br />

$.path.to.your.library.greetLib<br />

○ Additional properties for the newly generated library object:<br />

$.path.to.your.library.greetLib.greet()<br />

$.path.to.your.library.greetLib.greetingSuffix<br />

$.path.to.your.library.greetLib.greetingPrefix<br />

○ Pre-import checks:<br />

○ It is not possible to import the referenced library if the import operation would override any<br />

predefined runtime objects.<br />

○ Do not import the referenced library if it is already present in the package.<br />

○ Library context<br />

Imported libraries exist in the context defined by their repository location.<br />

9.4 Server-Side JavaScript APIs<br />

<strong>SAP</strong> <strong>HANA</strong> Extended Application Services (<strong>SAP</strong> <strong>HANA</strong> XS) provides a set of server-side JavaScript application<br />

programming interfaces (API) that enable you to configure your applications to interact with <strong>SAP</strong> <strong>HANA</strong>.<br />

The <strong>SAP</strong> <strong>HANA</strong> XS API Reference lists all the functions that are available for use when programing interaction<br />

between your application and <strong>SAP</strong> <strong>HANA</strong>. For example, you can use the database API to invoke SQL statements<br />

from inside your application, or access details of the current HTTP request for <strong>SAP</strong> <strong>HANA</strong> data with the requestprocessing<br />

API.<strong>SAP</strong> <strong>HANA</strong> XS includes the following set of server-side JavaScript APIs:<br />

● Request-Processing API<br />

Enables access to the context of the current HTTP request, for example, for read requests and write<br />

responses. You can use the functions provided by this API to manipulate the content of the request and the<br />

response.<br />

● Database API<br />

Enables access to the <strong>SAP</strong> <strong>HANA</strong> by means of SQL statements. For example, you can open a connection to<br />

commit or rollback changes in <strong>SAP</strong> <strong>HANA</strong>, to prepare stored procedures (or SQL statements) for execution or<br />

to return details of a result set or a result set's metadata.<br />

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

Writing Server-Side JavaScript Applications<br />

P U B L I C<br />

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

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

Saved successfully!

Ooh no, something went wrong!