SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for SAP HANA and ABAP, HANA Database, SQLScript, SAP UI5, Screen Personas, Web Dynpro, Workflow

Download and Install SAP HANA Graph Viewer and Query Graph Workspace


To install SAP HANA Graph Viewer to work on relational vertex and edge data on a graph visually, SAP HANA database developers can download and install SAP HANA Graph Viewer. Besides visualizing vertices and edges of a graph workspace, HANA Graph Viewer enables developers to create SQL queries easily protecting them from the complexity of Graph language or GraphScript.

In SAP note 2306732, GraphViewer is described as a visualization tool for SAP users to interact with created graph workspaces in a SAP HANA system.


Download SAP HANA Graph Viewer Visualization Tool

Let's start to download SAP HANA Graph Viewer and complete Graph Viewer installation step by step.

SAP users can free download SAP HANA Graph Viewer from SAP Software Downloads portal (service marketplace).
In Downloads search for "SAP HANA GRAPH VIEWER"

download SAP HANA Graph Viewer

Downloadable setup file for SAP HANA Graph Viewer visualization tool is HCOGRAPHVIEWER12_4-70001725.ZIP
As seen in following screenshot the total size is just 92.3 KB

SAP HANA Graph Viewer setup download


Install SAP HANA Graph Viewer Delivery Unit

When SAP users unzip the compressed download file, they will see HCOGRAPHVIEWER.tgz archive file.
Actually this is a Delivery Unit for the Graph Viewer that we will import to our SAP HANA database system soon.

contents of Graph Viewer download file

To import the delivery unit into target HANA database, on SAP HANA Studio Systems window, connect to the target HANA system.

connect to HANA system

Then follow menu options: File > Import...

When the Import wizard is displayed on the screen, drill-down to SAP HANA Content > Delivery Unit

Import Delivery Unit into SAP HANA wizard

Press Next button.

Select the target HANA system for import delivery unit operation, actually the SAP HANA system where you want to install SAP HANA Graph Viewer tool.

HANA system to install SAP HANA Graph Viewer tool

Click Next to continue.

To import the delivery unit provided for SAP HANA Graph Viewer we have just downloaded from SAP Software Downloads portal, choose option "Client" and point the .tgz file "HCOGRAPHVIEWER.tgz" in File selection by browsing with Windows Explorer.

import Graph Viewer delivery unit to SAP HANA

An import simulation process will execute and display simulation results as seen in below screenshot.

delivery unit import simulation for Graph Viewer component

If it is all Green then click Finish to complete the import task of SAP HANA Graph Viewer tool delivery unit into selected HANA system.

The result of the import delivery unit of Graph Viewer can be displayed on Job Log window within SAP HANA Studio IDE.

Job Log for Import Graph Viewer Delivery Unit


Create User on HANA Database for GraphViewer

Let's now create a HANA database user to work with virtualization tool GraphViewer which will help us avoid GraphScript language. And then grant SELECT on schema where the graph database table will be created. It is possible to use your own user for logon to SAP HANA Graph Viewer application, if so you will not require a database user. Neither you have to grant SELECT permissions on the target schema, too.

CREATE USER GVDEVELOPER PASSWORD "GVDevU_01*";
GRANT SELECT ON SCHEMA KODYAZ TO GVDEVELOPER;
Code

Launch SAP HANA Graph Viewer Visualization Tool

Launch a web browser and then navigate to URL "http://[saphanaserver:80][instancenumber]/sap/hana/graph/viewer/" for SAP HANA Graph Viewer.

If you don't know the SAP HANA server address of your target system, you can find it on the Administration console that can be launched within SAP HANA Studio via context menu on the target HANA system: "Configuration and Monitoring > Open Administration"
80 is the default port. Following two digit number is the instance number. You will find this information again on the Administration console.

logon to SAP HANA Graph Viewer

I know you have been dissapointed with the first screen of SAP HANA Graph Viewer.

initial screen of SAP HANA Graph Viewer

That is because we have not yet defined any Graph WorkSpace in our HANA database.
Then SAP developers can see the power of Graph Viewer as a virtualization tool and as a graphical tool to convert Graph Language commands into SQLScript code.
That is a very important feature of Graph Viewer. Important because, Graph language is has similiarities with SQL and SQLScript but has important limitations and differences that can hurt database developers as a programmer :)
But Graph Viewer provides parametric SQL Views (created from HANA database procedures by using the With Result View extension) to query Graph data using SQLScript instead of coding pure Graph Language.


Create HANA Database Graph Workspace using SQLScript

For demo purposes, SAP HANA Academy provides sample Graph scripts that you can find at github.com. But I will try to create a very simple Graph workspace for SAP users.

Let's create two tables; one for Vertex data and the other table is for Edge data.
Here is the SQLScript DDL codes for table creation.

-- Vertex table
create column table GraphVertex (
ID varchar(20),
PRIMARY KEY ("ID")
);

create column table GraphEdge (
ID int generated by default as identity(start with 1 increment by 1) not null,
Source varchar(20) not null,
Target varchar(20) not null,
PRIMARY KEY ("ID")
);
Code

I want to share a few important notes with SAP developers at this point.
Both tables, vertex and edge tables must have primary key for enabling unique values for key columns in below Create Graph Workspace command
And tinyint column type, for example, is not supported as a valid KEY COLUMN data type. But you can use Int, BigInt, Varchar and NVarChar data types for Key Columns.
Additionally, the source column and the target column of the edge table must have NOT NULL constraint.

Let's now populate some sample data into HANA Graph tables (vertex and edge tables)

-- Vertex; cities
insert into GraphVertex values ('Ankara');
insert into GraphVertex values ('Eskisehir');
insert into GraphVertex values ('Istanbul');
insert into GraphVertex values ('Antalya');
insert into GraphVertex values ('Izmir');

-- Edge; connections between cities
insert into GraphEdge (Source, Target)
select 'Ankara','Eskisehir' from dummy
union all
select 'Ankara','Istanbul' from dummy
union all
select 'Ankara','Antalya' from dummy
union all
select 'Eskisehir','Istanbul' from dummy
union all
select 'Eskisehir','Antalya' from dummy
union all
select 'Eskisehir','Izmir' from dummy
union all
select 'Izmir','Antalya' from dummy
union all
select 'Istanbul','Izmir' from dummy;
Code

Let's not create our first Graph Workspace on our SAP HANA system using SQLScript command "Create Graph Workspace" command as follows:

CREATE GRAPH WORKSPACE "SAMPLEGRAPHWORKSPACE"
 EDGE TABLE "GRAPHEDGE"
  SOURCE COLUMN "SOURCE"
  TARGET COLUMN "TARGET"
  KEY COLUMN "ID"
 VERTEX TABLE "GRAPHVERTEX"
  KEY COLUMN "ID";
Code

Work with SAP HANA Graph Viewer

Now we have our sample data in our Vertex and Edge tables and created our first Graph Workspace on our HANA database.
Let's launch HANA Graph Viewer tool again and select recently created graph workspace on the dropdown on initial screen.

sample Graph WorkSpace data on SAP HANA Graph Viewer visualization tool

Database developers can easily understand and learn the Graph Viewer toolbar.
But it is important to understand the Graph Interaction tool within the GraphViewer.
This section enables Graph database developers to create SQLScript codes replacing the necessity for creating HANA procedures created with Graph language

For example, in Neighborhood Search tab, database developer can query Graph Workspace data so that the list of cities that are directly connected to Izmir can be queried as follows.

query Graph Workspace using SAP HANA Graph Viewer

The resultant cities are seen with black color on the Graph. You see it is very simple querying and searching for vertex (or nodes) that you are searching for.

And if you click on the downward arrow button (like a download button), it displays the SQLScript query to get the same result for database developer.

get SQL code for Neighborhood using Graph Viewer visualization tool

You see following is the SQL query generated by the Graph Viewer

SELECT * FROM GRAPHDEVUSER.GET_NEIGHBORHOOD
WITH PARAMETERS (
'placeholder' = ('$$startVertices$$', '["Izmir"]'),
'placeholder' = ('$$direction$$','"incoming"'),
'placeholder' = ('$$minDepth$$','1'),
'placeholder' = ('$$maxDepth$$','1'),
'placeholder' = ('$$vertexFilter$$','""'),
'placeholder' = ('$$edgeFilter$$','""'));
Code

Shortest Path

Following is the shortest path query from Istanbul to Antalya

find the shortest path using Graph Viewer on SAP HANA

And the result in the visualization tool

shortest path query on SAP HANA Graph WorkSpace


Tutorials and Reference Documents for Graph on SAP HANA

Please check gitHub for SQLScript samples provided by SAP HANA Academy and please have a look at the online video Graph tutorials publihed at youtube.
Another resource which can be used for SAP professionals who want to work with Graph data is Graph Processing with SAP HANA 2

GraphScript, Graph Language reference is reachable at SAP HANA Graph Reference and SAP HANA database developers can find a downloadable PDF document here.



SAP HANA and ABAP

Install SAP Free
CRM Companies List
Web Based CRM Software


Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.