Updating HANA tables from reporting tool Page 1 Author – Ramkumar Rajendran Author Biography Ramkumar Rajendran Ramkumar Rajendran is a Consultant at a leading firm with an experience of 4 years. He has specialized in various tools like SAP HANA, SAP BI, SAP BO (Xcelsius, Webi and IDT), Tableau, Lumira and HadoopHive. He has worked upon the Sentiment Analysis of Twitter data. He has involved in the integration of HANA and Hadoop. He has worked on multiple implementation projects for various industry sectors. . Page 2 Author – Ramkumar Rajendran Table of Contents 1 About this document ..................................................................... 4 2 Introduction .................................................................................. 5 SAP HANA ........................................................................................... 5 SAP HANA extended application services ........................................... 5 3 Design Plan ......................................... Error! Bookmark not defined. 4 Case study update from Tableau, Qlikview and Xcelsius ................. 7 SAP HANA table .................................................................................. 7 Server Side Application built using JavaScript .................................... 8 HANA Table view of the record to be changed ................................. 10 Tableau Solution ............................................................................... 11 How the Tableau Solution works ...................................................... 13 Qlikview Solution .............................................................................. 14 Xcelsius Solution ............................................................................... 15 Other Reporting tools ....................................................................... 15 5 Summary ..................................................................................... 16 6 Reference Material ...................................................................... 16 Page 3 Author – Ramkumar Rajendran About this document Updating database tables from the reporting tools like Tableau, Qlikview, Xcelsius, etc. was considered to be a myth earlier and believed to be possible only specialized application like Business planning and consolidation, Integrated planning etc. These reporting tools were believed to be just used for visualizing the underlying data from the database through various graphs and charts. This paper describes the possibility of updating tables from various reporting tools with an innovative solution. As a pre-requisite to go through the document, it is expected that the user is aware of basic SAP HANA functionalities, basic features of Tableau, Qlikview and Xcelsius and JavaScript concepts. Page 4 Author – Ramkumar Rajendran Introduction SAP HANA SAP HANA is an innovative in-memory database and data management platform, specifically developed to take full advantage of the capabilities provided by modern hardware to increase application performance. By keeping all relevant data in main memory, data processing operations are significantly accelerated. Design for scalability is a core SAP HANA principle. SAP HANA can be distributed across many multiple hosts to achieve scalability in terms of both data volume and user concurrency. Unlike clusters, distributed HANA systems also distribute the data efficiently, achieving high scaling without I/O locks. The key performance indicators of SAP HANA appeal to many of our customers, and thousands of deployments are in progress. SAP HANA has become the fastest growing product in SAP’s 40+ year history. SAP HANA Extended Application Services SAP HANA Extended Application Services (SAP HANA XS) provide applications and application developers with access to the SAP HANA database using a consumption model that is exposed via HTTP. In addition to providing application-specific consumption models, SAP HANA XS also host system services that are part of the SAP HANA database. For example: search services and a built-in Web server that provides access to the static content stored in the SAP HANA repository. The consumption model provided by SAP HANA XS focuses on server-side applications written in JavaScript. Applications written in server-side JavaScript can make use of a powerful set of specially developed API functions, for example, to enable access to the current request session or the database. Page 5 Author – Ramkumar Rajendran Design Plan The technique of updating the HANA tables from the reporting tools is heavily built around a server side application developed with JavaScript code, which gets invoked from the report and the relevant data is passed as parameter to this code in the HANA server. With the availability of these parameters the server side application is executed resulting in update of the values in the tables. In order to update data into HANA table would require passing of 3 parameters to application layer, namely 1. Primary keys to distinguish a unique record. 2. Name of the column. 3. Value which needs to be updated in the table. Reporting Tools The server side application in HANA Webserver is invoked and parameters are passed resulting in update of HANA tables Webserver-HANA Database-HANA As depicted in the above figure the server side application is called which residing in the Webserver of HANA database and the relevant parameters are passed from the reporting tools to this application. This code further executes to update the HANA database tables, which is thinly coupled with the Webserver resulting in immediate update of the table with the passed parameter. Page 6 Author – Ramkumar Rajendran Case Study – Update data from Tableau, Qlikview and Xcelsius SAP HANA Table Let’s assume that we have a table in SAP HANA, named “BANK_INDICATORS” with the following structure. With regard to our earlier mention, the primary keys of the table have to be noted which is “COUNTRY” and “DATE” in this case. The value of these key fields needs to be passed from the reporting layer to identify a unique record in the table. The initial set of data in the table would be looking like this. Page 7 Author – Ramkumar Rajendran Server Side Application built using JavaScript SAP HANA Extended Application Services (SAP HANA XS) helps in hosting a server-side application written in JavaScript. We would utilize the potential of this application in our case study to update the HANA table with the parameters passed while invoking the application. switch (field) { case 'COUNTRY': conn.prepareStatement("SET SCHEMA \"HANA\"").execute(); var st = conn.prepareStatement("UPDATE \"HANA\".\"BANK_INDICATORS\" SET \"COUNTRY\" = ? WHERE \"COUNTRY\" = ?"); st.setString(1,data); st.setString(2,cname); break; case 'DATE': conn.prepareStatement ("SET SCHEMA \"HANA\"").execute(); var st = conn.prepareStatement("UPDATE \"HANA\".\"BANK_INDICATORS\" SET \"DATE\" = ? WHERE \"COUNTRY\" = ? AND \"DATE\" = ?"); st.setString(1,data); st.setString(2,cname); st.setString(3,date); break; case 'INTERNET_USERS': conn.prepareStatement("SET SCHEMA \"HANA\"").execute(); var st = conn.prepareStatement("UPDATE \"HANA\".\"BANK_INDICATORS\" SET \"INTERNET_USERS\" = ? WHERE \"COUNTRY\" = ? AND \"DATE\" = ?"); st.setString(1,data); st.setString(2,cname); st.setString(3,date); break; Page 8 Author – Ramkumar Rajendran case 'MILITARY_EXPENDITURE': conn.prepareStatement("SET SCHEMA \"HANA\"").execute(); var st = conn.prepareStatement("UPDATE \"HANA\".\"BANK_INDICATORS\" SET \"MILITARY_EXPENDITURE\" = ? WHERE \"COUNTRY\" = ? AND \"DATE\" = ?"); st.setString(1,data); st.setString(2,cname); st.setString(3,date); break; case 'GDP_PERCAPITA': conn.prepareStatement("SET SCHEMA \"HANA\"").execute(); var st = conn.prepareStatement("UPDATE \"HANA\".\"BANK_INDICATORS\" SET\"GDP_PERCAPITA\" = ? WHERE \"COUNTRY\" = ? AND \"DATE\" = ?"); st.setString(1,data); st.setString(2,cname); st.setString(3,date); break; case 'LIFE_EXPECTANCY': conn.prepareStatement("SET SCHEMA \"HANA\"").execute(); var st = conn.prepareStatement("UPDATE \"HANA\".\"BANK_INDICATORS\" SET \"LIFE_EXPECTANCY\" = ? WHERE \"COUNTRY\" = ? AND \"DATE\" = ?"); st.setString(1,data); st.setString(2,cname); st.setString(3,date); break; } Page 9 Author – Ramkumar Rajendran HANA Table view of the record to be changed Consider the below view of the table “BANK_INDICATORS”. Assume that we need to change the “LIFE_EXPECTANCY” of the record which is highlighted in the below figure to ‘60’. It should be noted that key fields include COUNTRY and DATE, which in this case are ‘Albania’ and ’01-Jul-2006’. Page 10 Author – Ramkumar Rajendran Tableau Solution Create a Tableau dashboard with live connection to SAP HANA which would look like below. Enter the new value for the field as 60 and choose the field which needs to be updated from the drop down box. Right click anywhere in the dashboard and select “Update new value for LIFE_EXPECTANCY” Page 11 Author – Ramkumar Rajendran Refresh the Tableau dashboard and we could see that the value for LIFE_EXPECTANCY is updated as ‘60’ in the dashboard. And the same value can be seen updated in the HANA table level. Page 12 Author – Ramkumar Rajendran How the Tableau Solution works? A text input area for the new value and a drop down box for the field names is created as shown in the below figure. A URL action is created which is associated with the parameters “Enter updated data” and “Select Field” and the dashboard. http://10.118.0.80:1080/HANA_PAPER/HANA_PAPER/bank.xsjs?field=<Parameters.Select Field>&cname=<COUNTRY>&cdate=<DATE>&data=<Parameters.Data> This URL action as mentioned above dynamically collects the relevant parameters, viz. primary keys of the HANA table (COUNTRY and DATE), the new value (60) and the field which needs to be updated (LIFE_EXPECTANCY) and executes the server side application at the HANA webserver level with these parameters which in turn would update HANA database table with these parameters. Page 13 Author – Ramkumar Rajendran Qlikview Solution On the same lines the dashboard in Qlikview will also help in updating HANA tables. The dashboard will look as follows. In this case we are required to explicitly ask the key field information apart from the new value and field name information from the users since the same functionality can’t be performed here In addition to what have been done for Tableau, we are expected to manually fetch the data of each relevant field through manual variables. Also a bit of macro coding is required to give a better user experience. Page 14 Author – Ramkumar Rajendran Xcelsius Solution The dashboard built with Xcelsius will look as follows. In this case the new value will be updated on the basis of the correction done in the input text area available once any of the record is chosen. The link for the server side application in HANA webserver is embedded into one of the excel sheet present in the dashboard, which is called while clicking on the Update button. Other Reporting tools As per our research the same technique can be applied across majority of the reporting tools, except a few like Explorer and Lumira which doesn’t support URL actions. Page 15 Author – Ramkumar Rajendran Summary The combined potential of SAP HANA Extended Application Services and the various reporting tools have been utilized to accomplish a very enthralling solution. This technique can be applicable in scenarios where the users are expected to update values on a regular basis. It doesn’t serve as a complete replacement for SAP BPC, SAP IP, Hyperion, etc. But the myth of updating data to database from the reporting layer is broken. What we have illustrated over here is a simple mechanism to achieve this task. We can further customize this technique to accomplish much complex real time solutions. The same technique can be further extended to other tools like MicroStrategy, Spotfire, etc. References http://help.sap.com/hana/SAP_HANA_Developer_Guide_en.pdf http://scn.sap.com/community/developer-center/hana/blog/2012/12/21/hana-development-xs-odataservices http://www.tableausoftware.com/public/blog http://community.qlik.com/welcome http://everythingxcelsius.com/ Page 16 Author – Ramkumar Rajendran