Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 
Former Member
Hello Everyone!!

In this blog ,I will discuss on some cool stuff that I developed last week !!

With the power HANA on cloud and the ability to connect devices, it has become possible to access and control device from remote.

Let's have a use case where you are in your car on the way to office and suddenly you realize that you have an important file in your personal laptop that you need access.

To solve such problems we can take use of HANA to access to resources on your local system.

I will showcase the above by an application that shut down your laptop from SAPUI5 application running in your mobile.

The application functions as explained below:

1:-    When user press on Shutdown button in SAPUI5 application, the application reads the flag from          HANA using XSODATA intreface.

If the flag for shutdown is already set, application alerts system is already shutdown.

2:-   If the shutdown flag is not set ,application set the flag for shutting down the laptop

3:-   There is a java application running in your laptop that checks for the status of the flag after                  every fix interval of time.

4:-   If the flag is set ,the java application initiates system shutdown .

5:- Along with shutdown initialization, java application unset the flag in HANA system.

So now let's code !!


1:- You have a HANA trial account.

2:- You have created a MDC trial schema.

3:- You have java installed in your local system.

Step 1:-

Create HANAXS application:

A:-   Create a package in  HANAXS editor.

B:- Create a .xsaccess and .xsapp files in the folder



C:- Create  shutStorage.hdbschema file
schema_name = "ShutStorage";

D:- Create a shut.hdbdd file
namespace shuttler;
@Schema: 'ShutStorage'
context shut {

Entity flagHolder{
key id: Integer;

E:- Create a accessShuttler.xsodata file
"shuttler::shut.flagHolder" as "flagHolder";

F:- Test the ODATA service by clicking on the run button. You will get a result like below in browser
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<service xmlns:atom="" xmlns:app="" xmlns="" xml:base="">
<collection href="flagHolder">


After Completing the above steps our HANAXS application is ready :).

Note: Create a row inside the table with entry 1 ,0 for id and flag respectively.

Step 2:- Create SAPUi5 application

A:- Open SAP Webide and create  SAPUI5 application.

File->New->Project from template -> SAPUI5 Application

B:- Open the neo-app.json file in the newly created project and add the lines with red mark as shown below

Note: - It is required that you have created  destination for the HANAXS system in cloud cockpit as shown below

C:- Add following code in the view file inside content tag

 <Button text="Shut Down SYSTEM" id="__button1" press="onShutDownPress"/>

D:- Add the following code in your controller.js file

onShutDownPress: function () {
//var oModel=this.getView().getModel("sales");
// console.log(oModel);

var oModel = new sap.ui.model.odata.ODataModel("/HANAXS/shuttler/accessShuttler.xsodata");
oModel.setUseBatch(false);"/flagHolder(1)", null, null, true, jQuery.proxy(function(data) {
var oEntry = {};
oEntry.flag = "1";
oModel.update('/flagHolder(1)', oEntry, null, function(){
alert("Update successful");
alert("Update failed");});


alert("Your system is already shut down");

Test the ui5 application by clicking on the Shut down system button

Bingo!! Your UI5 application is ready

Step 3:- Create a java application in your local system

Check that java is installed in your local system.
(I am working on writing the code in pure OS command based eliminating the dependency of java.
Till then you have to bare with this .

A: Open any editor (notepad,notepad++ etc) and paste the following code
(Note:- Change the URL of HANAXS odata  accordingly)
import org.apache.commons.codec.binary.Base64;
import java.util.*;
import org.json.JSONArray;
import org.json.JSONObject;
public class ShutProcessor {
private final String USER_AGENT = "Mozilla/5.0";
public static void main(String[] args) {

Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {

public void run() {
ShutProcessor sP=new ShutProcessor();
}catch(Exception e){}

}, 0, 50000);

//System.out.println("Using proxy: " + host + ":" + port);
//String shutdownCmd = "shutdown -s";
// Process child = Runtime.getRuntime().exec(shutdownCmd);
catch(Exception e)

private void sendPut(URL obj) throws Exception
String url = "";
System.out.println("\nSending 'PUT' request to URL : " + url);
URL obj1 = new URL(url);
String req="<a:entry xmlns:a="" xmlns:m="" xmlns:d=""><a:author><a:name/></a:author><a:content type="application/xml"><m:properties><d:flag>0</d:flag></m:properties></a:content></a:entry>";
HttpURLConnection con = setUsernamePassword(obj1);

con.setRequestProperty("Content-Type", "application/atom+xml");
con.setRequestProperty("Content-Length", Integer.toString(req.getBytes().length));
con.setRequestProperty("Accept", "application/atom+xml,application/atomsvc+xml,application/xml");
con.setRequestProperty("Content-Type", "application/atom+xml");
OutputStreamWriter out = new OutputStreamWriter(
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();

while ((inputLine = in.readLine()) != null) {
private void sendGet() throws Exception {

String url = "$format=json";

URL obj = new URL(url);
HttpURLConnection con = setUsernamePassword(obj);;

// optional default is GET

//add request header
con.setRequestProperty("User-Agent", USER_AGENT);

int responseCode = con.getResponseCode();
System.out.println("\nSending 'GET' request to URL : " + url);
System.out.println("\nSending 'GET' request to URL : " + url);
System.out.println("Response Code : " + responseCode);

BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();

while ((inputLine = in.readLine()) != null) {

JSONArray jsonArray = new JSONArray("["+response.toString()+"]");
JSONObject rec = new JSONObject(response.toString());
String flg = rec.getJSONObject("d").getString("flag");

{ this.sendPut(obj);
String shutdownCmd = "shutdown -s";
Process child = Runtime.getRuntime().exec(shutdownCmd);

private HttpURLConnection setUsernamePassword(URL url) throws IOException {
HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
String authString = "<HANA_Instance_username>" + ":" + "<HANA_Instance_password>";
String authStringEnc = new String(Base64.encodeBase64(authString.getBytes()));
urlConnection.setRequestProperty("Authorization", "Basic " + authStringEnc);
return urlConnection;

B:- Compile the program using the javac command.

C:- Run the program using java command.

D:- Create a shutProcess.bat file and include the java commands in the file.

E:- Include the bat file in the startup programs so that it runs as soon as the system starts

for help to run bat file at startup click here

Note: The java program make use of following jar files .You need to download them and add to your class path for the application to work properly.



Bingo!! Your application is ready. Now just press the shutdown system  button from your application and your laptop will shutdown !!

If you have any suggestions to improve or add to the application do suggest 🙂

Labels in this area