English

How To: Connect to a SAP HANA database with ArcObjects

Summary

At ArcGIS 10.3 and 10.3.1, developers can use ArcObjects to make a connection to SAP HANA data warehouses. Spatial data from the warehouse can then be used in ArcGIS. It is important to note that m- and z- valued data are not supported with SAP HANA spatial data, therefore avoid importing such data with ArcObjects.

Procedure

ArcGIS support for SAP HANA is implemented in ArcGIS 10.3 and later. Connection to the SAP HANA data warehouse with any of the current versions of ArcGIS (either ArcGIS 10.3 or 10.3.1) is possible and also enables complex spatial analyses on a subset of your spatial data.

  1. Read the system requirements to review the supported SAP HANA data warehouses and ODBC driver versions and to ensure your machine meets the minimum requirements prior to installing and configuring the client.
    The first step to initiating a connection is to ensure that the SAP HANA ODBC driver on the client machine has been installed and accurately configured. How to connect to SAP HANA from ArcGIS details the steps needed to ensure the creation of an ArcGIS-SAP HANA connection.
    Note:
    Spatial data is stored in the SAP HANA ST_Geometry type which is part of the default SAP HANA data warehouse installation.
  2. The following key points can help developers when using Engine/ArcObjects with SAP HANA.
    · SAP HANA data is self-indexing with the use of columnar data storage. So there is no requirements for spatial index for query performance on the spatial columns.
    · There is no support for z- or m- coordinates as the SAP HANA ST_Geometry type only supports two-dimensional spatial data. Therefore avoid importing spatial data with either z- or m- coordinates.
    · In most cases, SAP HANA data warehouses have large amounts of data; developers are advised to subset the data that needs to be analyzed for performance reasons. This can be defined by using a query definition or create a database view with only the subset of interest.
  3. Below is a code snippet that demonstrates connection to SAP HANA database from ArcObjects. Note that with the below method, the required connection file is the .sde file created in step 1 above.
    Code:
    
                    public static void testWithISqlWorkspace(String connectionFile) throws AutomationException, IOException{	
    
    		IWorkspaceFactory workspaceFactory = new SdeWorkspaceFactory();
    		IWorkspace workspace = workspaceFactory.openFromFile(connectionFile, 0);		
    		ISqlWorkspace sqlWorkspace = new SqlWorkspace(workspace);		
    		//define query description to subset your data
    		String query = "Select * from TESTUSER.TABLEONE"; //build a better query to subset
    		IQueryDescription queryDesc = sqlWorkspace.getQueryDescription(query);
    		
    		//proceed to use queryDesc as needed. eg. print out the field names
    		for(int i=0; i < queryDesc.getFields().getFieldCount(); i++){
                    System.out.println("Field Name at index "+ i+" is: "+queryDesc.getFields().getField(i).getName());
    		}
    		}
    
    Warning:
    There is currently no support for connection in ArcGIS Pro either via any UI or the Pro SDK.