Skip to Content
Author's profile photo Former Member

SAP River(1)—SAP River overview

We have a Chinese version (SAP River ()SAP River概述) of this blog.


The most common architecture of SAP HANA application is like below(From SAP River Datasheet):


Figure 1: Traditional SAP HANA application architecture

   With the traditional architecture shown in Figure 1, application developer is responsible for both creating  data model in database level  and implementing control logic in XS level. SQL and SQL Script are required to create data model in SAP HANA database, while xsjs needed to implement control logic in XS level. Therefore, the developer of SAP HANA application at least needs to grasp two technologies to finish a SAP HANA application. Sometimes, developing a SAP HANA application needs the cooperation of two or more developers. SAP River is an option to void this problem.

   SAP River is a brand new method to develop SAP HANA application. SAP River consists of a programming language, a programming model and a suit of development tools. With help of SAP River, developer can concentrate on the design of business intent, ignoring how is it implemented and optimized in SAP HANA database.  SAP River only exists in design-time. When SAP River objects activated, all SAP River code is compiled into SQL Script or XSJS code and then transferred to XS engine indexserver for execution.


Figure 2: Function model of SAP River

The function model is shown in Figure 2 (From SAP River Datasheet). SAP River integrates all the segments involved in development of SAP HANA application, including data modeling, control logic and access control, which makes developer capable of accomplishing a SAP HANA application grasping only one single technology. Firstly, developer can design the data model for SAP HANA application with SAP River language. During compilation, SAP River will create corresponding database objects for the data model you designed using SAP River language. For example, the entity in SAP River program will be mapped to a table in SAP HANA database. Secondly, using SAP River language, developer can define methods for data objects, which implements business logic. Last but not least, SAP River provides developer a way to design the access control for data and method.

SAP River Language

      As a new generation of SAP HANA application development method, SAP River provides a strongly typed and declarative programing language. With this programming language, even a non-computer-major developer can also easily develop a SAP HANA application. In addition, SAP River also supports embedded SQL Script and XSJS code in SAP River program, which is useful for some complicated logic.

      SAP River Language mainly includes:

  1. Application: Application is the largest object in SAP River Language, all other objects must be included in an application. Objects in an application can be exposed to external applications via some ways, such as OData.
  2. Entity: Entity is used to store data in database. Usually, one entity is mapped to a table in SAP HANA Database. An entity consists of one or more elements. Usually, one element is mapped to a column of a table. Each element has its own type, the type here can be fundamental type such as integer, string, and can also be a custom type or entity.
  3. Types: Type defined the size and validity of data. SAP River supports different kinds of types, including fundamental type, structured type and stream type. Each entity will automatically define a corresponding implicit type, which has same name with the entity.
  4. Action: Action is similar to the function or method in other programming languages. Usually, SAP River define the business logic of the application in the actions.
  5. View: With the help of view, you can create a data stream using select statement, this data stream is a subset of target data set. The data of this data stream will be dynamically extracted from target data set when the data stream is used.
  6. Role: Role can be created in SAP River code, and assigned some privileges to this role. In this way, access control is implemented.


Figure 3. SAP River example program: Hello World

      As a programming language, SAP River also provides some libraries, which contains many common functions. These libraries can be divided to some categories according to their functionality:

  1. Math Functions: mathematic calculation functions, such as absolute, ceil, floor, etc.
  2. Integer Functions: process the data of integer type, such as toDecimalFloat, toString, etc.
  3. String Functions: deal with strings, such as length, substring, etc.
  4. Date Functions: date functions, such as day, month, etc.
  5. Session Functions: session functions, such as getUserName.
  6. Logging Functions: log function, such log.
  7. Utility Functions: some utility functions, such as parseDecimalFloat, parseInt, etc.
  8. HTTP Calls: Http library is used to send Http request in SAP River code, such as OData or REST services.

OData Calls

      SAP River can expose the data and business logic to client via OData protocol. SAP River can expose data to client either in application level or in namespace level via OData. If exposed in namespace level, then every entities, views, and actions in this namespace are exposed to client. If exposed in application level, then only the objects that are tagged for exposure are exposed to client. Here, let’s take application level as example to illustrate how to expose data via OData.


Figure 4. Expose SAP River application via OData

   ① when expose object in application level, you must use the keyword export to specify which objects are to be exposed to client. Such as Employee in TestSyntax here.

   ② There are more than one ways to expose SAP River object, OData is one of them. So it is necessary to add a notation “@OData” to declare the way of exposure. SAP River will create corresponding OData service for the application or namespace.

   ③ By Default, SAP River object is private. To let specified users to access certain object, you need to use the keyword “accessible by” to tell which role or privileges are required to access the object.  If every users are allowed to access, you can just use “accessible by sap.hana.All”.

How to learn SAP River

      SAP HANA begin to support SAP River from SPS07, we have many materials to study SAP River. Here are some materials for studying SAP River:

  1. SAP River Datasheet
  2. SAP River Help Docs
  3. Videos and PPTs introducing SAP River
  4. Series of videos introducing SAP River in SAP Academy


        In this blog, we talked about functionality of SAP River, advantage and structure, including the advantages of SAP River over traditional development framework, main features of SAP River and how to expose data to client via OData.


  1. SAP River Datasheet
  2. SAP River Language Reference
  3. SAP River Developer Guide

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Daniel Wroblewski
      Daniel Wroblewski

      The Chinese version is great!! Would it make more sense to simply add a link to the Chinese version on the top of the original document (SAP River Datasheet) instead of creating a second document?


      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi, Daniel. Thanks a lot for your great work in SAP River Datasheet, it helps me a lot. Yes, it is great idea to add a link. As i plan to write a series of SAP River, this is just a part of it. Thanks a lot again for your help!!! 🙂

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      And sorry for forgetting to add reference for the two Figures, added already. 🙂

      Author's profile photo Andrei Dorfman
      Andrei Dorfman

      Interesting... Accidentally stumbled upon this while preparing for certification. Is it used anymore or superseded by CDS tech? Any idea who invented this?