The SAP HANA Deployment Infrastructure (HDI) is a set of services that allows the independent deployment of database objects. It relies on HDI containers.
HDI containers are like a database schema but they come together with a dedicated owner and metadata to manage their contained database objects.
These objects are described in the HDB modules of multi-target applications, in design-time artifacts that are deployed by the HDI Deployer application; this Node.js application is materialized in the
<project>/db/node_modules/@sap/hdi-deploy folder, among other Node.js dependencies.
HDI takes care of dependency management and determines the order of activation; it also provides support for upgrading existing runtime artifacts when their corresponding design-time artifacts are modified.
One key concept of HDI containers is the fact that the entire lifecycle (creation, modification, and deletion) of database objects is performed exclusively by the HDI. Therefore, you cannot create database artifacts, such as tables or views, with Data Definition Language (DDL) statements in SQL.
Indeed, if you create a table in a container schema with a plain SQL statement, this means there is no design-time object for this table. So, upon deployment of the container, this table will not be recreated. Similarly, deleting a database object from your container with SQL will not remove its design-time counterpart, so the object will be recreated upon build and/or deployment.
Data Sources for Calculation Views
When you design calculation views, the data sources must exist as design-time files in the container of your HDB module. So they must be of one of the following types:
- "Real" database objects (table, view, table function, virtual tables, and so on) existing inside the container and having a corresponding design-time file in the HDB module
- Synonyms referencing database objects located in any other schema than the container itself. You will learn about synonyms later on.
A Calculation View using as a data source a table that was created by plain SQL in your container (so, without a design-time file) cannot be built. The build fails and issues an error message, such as:
The file requires "db://HA300::TABLE_SQL" which is not provided by any file
Key Properties of HDI Containers
A container generates a database schema.
Database objects are deployed into the schema.
Source file definitions must be written in a schema-free way.
Direct references to external schema objects are not allowed.
HDI Container Configuration File
Within each HDB module of a project you will find a very important and mandatory file that exists under the src folder with the suffix: .hdiconfig. This is the HDI container configuration file that is used to bind the design-time files of your project to the corresponding installed build plug-in.
Without the build plug-in it is not possible to build the run-time objects from the design-time files. This configuration file directs each source file in your project to the correct build plug-in.
Usually there is only one .hdiconfig file in a HDB module, and this must be located in the src folder of the HDB module. This file contains a list of all bindings for all source file types.
The minimum_feature_version entry of this file is there to prevent building your HDB module objects with a version of HANA Cloud that is lower than what is specified and/or what your code requires. For example, if you have designed and tested your HDB module with version 1004 of the build plug-ins, this will not deploy on an SAP HANA Cloud instance where version 1002 is in place.
Inside the container configuration file you will find, for each source file type, two entries:
suffix name, for example, "hdbcalculationview"
plug-in name, for example, "com.sap.hana.di.calculationview"
It’s very important to remember that when you import a project into your landscape, it brings with it its own .hdiconfig file that refers to the feature version that was used when it was first developed. If you then plan to update the source file using newer features of SAP HANA (for example, you want to add a new feature to a calculation view that just became available with the newer version of SAP HANA) you will not see the new feature in the source editor if the .hdiconfig file has not been adjusted to use the later feature version.
The HDI container configuration file is an unnamed file and must only consist of the suffix .hdiconfig. If you try to add a name, the build of the .hdiconfig file will fail. Leave it as it is.
The SAP HANA PROJECTS View
In SAP Business Application Studio, when a project includes an SAP HANA DB module, a dedicated view SAP HANA PROJECTS in available (alongside the Explorer view.
The SAP HANA Projects view/panel is the materialization of the HDB module(s) defined in your projects. The upper part represents the folder structure of the HDB module. The root element corresponds to the path to the HDB module in the project. To create the runtime objects inside the connected HDI container schema, you can execute a deployment. This deployment can be triggered at different levels: a single file, a folder, or the entire HDB module.
You cannot manipulate (move, copy, delete, etc) your design-time files from the SAP HANA PROJECTS view, but you can open them in their respective editor.
In the file structure, the mention Pending Deployment identifies where a deployment is required for new or modified files. For deleted design-time files, you need to "activate" the deletion by deploying the folder that contained them.
The lower part represents the Database Connections between the HDB module and the HDI containers or services providing access to external resources.
A project with an SAP HANA Database module needs at least a corresponding HDI Container to deploy its runtime objects. This is what is shown in the image, The SAP HANA PROJECTS View.
In the connection part, you can bind an existing HDB module to a new or existing HDI container. You can also add new connections (for example to another container), and
The Database Explorer
From SAP Business Application Studio, you can launch the Database Explorer application to view the database artifacts (tables, views, procedures, column views) of one or several containers.
When you do this, even if you are logged on to the SAP Web IDE with your usual SAP Web IDE user, access to the container is done by a technical SBSS (Service Broker Security Support) user that is created transparently when you add the container to the Database Explorer. This technical user interacts with the database objects on your behalf, for example, to view the content of a table or preview the data of a calculation view.
If your container consumes data from an external schema, the technical user must also be granted authorizations to the external schema objects, for example, to view the data of an external table referenced by a synonym. You will learn more about this in the unit, Security in SAP HANA Modeling.
The Database Explorer also allows you to connect to classic database schemas, not managed by the HANA Deployment Infrastructure, to show the database objects and the content of tables, execute queries in a SQL console, and so on.