Skip to Content
Technical Articles
Author's profile photo yasuyuki uno

Managing HANA Service automatically. Scheduled Start/Stop. Part.1

Today, I published a library for managing HANA Service. I write to this blog why I needed this library.

Background of this article

Our customer contracts a consumption-based commercial model for SAP Cloud Platform. In the case of a CPEA contract, the HANA Service is pay-per-use based on start-up time, which can be very costly if it has been running 24 hours a day.

For example, a 24-hour running with HANA Service 32GB memory costs about 700 EUR per month. If it can be stopped for 12 hours a day, it is possible to compress the cost to about half.
In particular, isn’t it necessary to keep the development environment DB running for 24 hours?

However, manually starting and stopping the HANA Service is very cumbersome and is likely to be forgotten.
I wrote this article, thinking that I could somehow automate the startup / shutdown of the HANA Service Instances.

There are two existing ways to start / stop HANA Service.

  1. HANA Service Dashboard. (existing ways)
  2. Start / Stop Command with CF CLI. (existing ways)
  3. My library (new ways)

Certainly, if you write a script for batch execution of CF CLI and register it in the Windows Task Scheduler, it seems that you can automatically start / stop the HANA Service. However, I can not afford to keep my PC running for 24 hours.

So, I needed to manage the HANA Service from Node.js.

Roughly speaking, CF CLI is just running the REST API in the background.

Appendix: CF CLI TRACE

If you want to check whether what I’m saying (it can replace “CF commands” to “REST API”) is true, try setting the environment variable CF_TRACE to true and executing the CF commands.

In Windows:

set CF_TRACE=true
cf login

You can inspect the HTTP requests of a CLI command by setting CF_TRACE=true.

How to use cf-nodejs-client? What can it do?

cf-nodejs-client is a CF client library for Node.js.
I modified it by adding methods required to operate HANA Service. I will show you how to use it.


  • SAP HANA Service instance in CF environment.
  • Install Node.js on your PC

Outline of the procedure

  1. Create a Node.js project.
  2. Run the app locally.
  3. Deploy the app to CF. (Next blog)


1.Create a Node.js project.

Open Command Prompt and move to your workspace directory. In my case, the workspace is “D:\html5”.

cd /d D:\html5

Make project folder. In this time, I named “hana_controller”.

mkdir hana_controller
cd hana_controller

Create package.json file like following.

  "name": "hana_controller",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node app.js"
  "dependencies": {
    "cf-nodejs-client": "git+"

Then install the library.

npm install

Create app.js file like following.



const endpoint = "";  // Change here if you're not use CF-frankfurt.
const username = "SAPCP_USERNAME"; // Change here
const password = "SAPCP_PASSWORD"; // Change here

const CloudController = new (require("cf-nodejs-client")).CloudController(endpoint);
const UsersUAA = new (require("cf-nodejs-client")).UsersUAA;
//const Apps = new (require("cf-nodejs-client")).Apps(endpoint);
const ServiceInstances = new (require("cf-nodejs-client")).ServiceInstances(endpoint);

CloudController.getInfo().then( (result) => {
    return UsersUAA.login(username, password);
}).then( (result) => {
    return ServiceInstances.start("YOUR_HANA_SERVICE_ID"); // Change here
    //return ServiceInstances.stop("YOUR_HANA_SERVICE_ID");
}).then( (result) => {
}).catch( (reason) => {
    console.error("Error: " + reason);

Please refer to the HANA dashboard for the “YOUR_HANA_SERVICE_ID” as shown below.


2.Run the app locally.

Run the application by

node app.js

Your HANA DB should have started.

In the next article, I will write about how to deploy this application to the cloud and how to schedule the start / stop of HANA DB.

Also, if there is extra capacity, the library will be updated and all commands for HANA Service operation will be supported.

Assigned Tags

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

      I really like this blog!  It contains step by step how to recreate the program.  It also tells us WHY you are doing it.  I like that extra information.

      Author's profile photo yasuyuki uno
      yasuyuki uno
      Blog Post Author

      Thanks for a comment and following me. Yes, I always try to write WHY and extra information.

      I would like to update the library so that HANA operation and SAP CP operation can be performed without Web Browser and CF CLI.

      Author's profile photo Neo Kung
      Neo Kung



      Really good stuff! Thanks for sharing.

      Author's profile photo Christiano Hage
      Christiano Hage

      Hi yasuyuki uno, would this script also work for the new HANA Cloud? Regards, Chris

      Author's profile photo Carlos Lopez
      Carlos Lopez

      Hi Christiano, did you try this script to HANA Cloud? I'm looking a service like this.


      Regards, Carlos.

      Author's profile photo Christiano Hage
      Christiano Hage

      Hi Carlos, I tried in the past and it did not work... I believe I was using a Linux syntax on a Windows machine... Then I did not try that anymore. Regards