LIBNAME Statement for the SAP HANA Engine

Overview

This section describes the LIBNAME statement that SAS/ACCESS Interface to SAP HANA supports. For general information about this feature, see LIBNAME Statement for Relational Databases.

Here is the LIBNAME statement syntax for accessing SAP HANA.

For general information about the LIBNAME statement that is not specific to SAS/ACCESS, see LIBNAME Statement in SAS Global Statements: Reference.

Arguments

libref

specifies any SAS name that serves as an alias to associate SAS with a database, schema, server, or group of tables and views.

saphana

specifies the SAS/ACCESS engine name for the SAP HANA interface.

connection-options

provide connection information and control how SAS manages the timing and concurrence of the connection to the DBMS. When you use the LIBNAME statement, you can connect to the SAP HANA server in many different ways. Specify only one of these methods for each connection because they are mutually exclusive.

  • SERVER=, PORT=, USER=, PASSWORD=
  • SERVER=, INSTANCE=, USER=, PASSWORD=
  • DSN=, USER=, PASSWORD= [This method uses a configured ODBC data source to store the connections options.]
  • NOPROMPT=
  • PROMPT=

Here is how these options are defined.

Note: All of the following connection options are also valid in the CONNECT statement when you use the SQL pass-through facility (SQL procedure) to connect to your DBMS.
SERVER=<'>server-name<'>
SERVER=<'>server-name:port<'>
SERVER='server-name:port;failover-server-name1:port;failover-server-name2:port'

specifies the server name or IP address of the SAP HANA server to which you want to connect. If the server name contains spaces or nonalphanumeric characters or if it is an IP address, you must enclose it in quotation marks. You can include the port when you specify a server. The port number is 3<instance-number>15 (for example, 30015 for the instance number 00). To support failover, you can specify a list of hostnames, separated by a semicolon. If a host is not available, the next host from the list is used.

Alias: HOST, SERVER, SERVERNODE

Example: SERVERNODE='saph1.mycompany.com'

PORT=port

specifies the port number that is used to connect to the specified SAP HANA server. The default is used if you do not specify a port or instance number or if you do not include the port number in the server specification. The port for the standard SQL communication for client access is 3<instance-number>15.

Restriction: Do not specify a value for both the PORT= and INSTANCE= options. If you specify a value for both PORT= and INSTANCE=, then the following error appears in the log:

ERROR: Invalid combination of connection errors. You cannot use the 
PORT with the INSTANCE option.

Alias: PORT

Default: 30015

Example: server=’saph1.mycompany.com’ port=30215

INSTANCE=instance-number

specifies the instance number of the SAP HANA database engine. The port number is 3<instance-number>15 (for example, 30015 for the instance number 00). If you specify the port number explicitly in either PORT= or SERVER=, then INSTANCE= is ignored and a warning is written to the SAS log.

Restriction: Do not specify INSTANCE= if you also specify a port value for PORT= or SERVER=. If you specify a value for both PORT= and INSTANCE=, then the following error appears in the log:

ERROR: Invalid combination of connection errors. You cannot use the 
PORT with the INSTANCE option.

Alias: INSTANCE

Example: server=’saph1.mycompany.com’ instance=02

USER=<'>SAP-HANA-user-name<'>

specifies the SAP HANA user name (also called the user ID) that you use to connect to your database. If the user name contains spaces or nonalphanumeric characters, you must enclose it in quotation marks.

Alias: USER

Example: USER=HANAUSER1

PASSWORD=<'>SAP-HANA-password<'>

specifies the password that is associated with your SAP HANA user name. If the password contains spaces or nonalphanumeric characters, you must enclose it in quotation marks.

Aliases: PASS, PASSWORD, PW, PWD

DSN=<'>SAP-HANA-data-source<'>

specifies the configured SAP HANA ODBC data source to which you want to connect. Use this option if you have existing SAP HANA ODBC data sources that are configured on your client. This method requires additional setup. You can perform setup either through the ODBC Administrator control panel on Windows platforms or through the odbc.ini file or a similarly named configuration file on UNIX platforms. It is recommended that you use this connection method only if you have existing, functioning data sources that have been specified.

Alias: DSN

Example: DSN=HANADSN1

Here is an example for an odbc.ini entry on UNIX:

[MYSAPHANA]
SERVERNODE=saph1.mycompany.com:30315
NOPROMPT=<'>SAP-HANA-connection-options<'>

specifies connection options for your database. Separate multiple options with a semicolon. If you do not specify enough correct connection options, an error is returned. No dialog box is displayed to help you complete the connection string. Connection options are appended to the connection string that is used to connect to the SAP HANA database. You can use this option to specify special options by adding key-value pairs to the connection string.

PROMPT=<'>SAP-HANA-connection-information<'>

specifies connection options for your database. Separate multiple options with a semicolon. When connection succeeds, the complete connection string is returned in the SYSDBMSG macro variable. PROMPT= does not immediately try to connect to the DBMS. A dialog box is displayed in SAS windowing environment instead that contains the values that you entered in the PROMPT= connection string. You can edit values or enter additional values in any field before you connect to the database.

Restriction: This option is not available on UNIX platforms.

DRIVER=<'>driver<'>

specifies the ODBC driver to use to connect to your database.

ENCRYPT=YES | NO

specifies how communication is encrypted.

Alias: ENCRYPT

Default: NO

SSLCRYPTOPROVIDER=SAPCRYPTO | OPENSSL

specifies the cryptographic library provider to use for SSL connectivity.

Note: Based on the SAP documentation, the OPENSSL value is deprecated and it is recommended that you migrate to CommonCryptoLib. For more information, see your SAP documentation.

Alias: SSLCRYPTOPROVIDER, SSLPROVIDER

SSLKEYSTORE=<'>file<'>

specifies the path to the keystore file.

Alias: SSLKEYSTORE

ODBC driver default: $HOME/.ssl/key.pem

SSLTRUSTSTORE=<'>file<'>

specifies the path to the truststore file.

Alias: SSLTRUSTSTORE

ODBC driver default: $HOME/.ssl/trust.pem

SSLVALIDATECERTIFICATE=YES | NO

indicates whether to validate the certificate of the communication partner.

Alias: SSLVALIDATECERTIFICATE

ODBC driver default: NO

SSLHOSTNAMEINCERTIFICATE=<'>string<'>

specifies the host-name certificate of the keystore.

Alias: SSLHOSTNAMEINCERT, SSLHOSTNAMEINCERTIFICATE

SSLCREATESELFSIGNEDCERTIFICATE=YES | NO

specifies whether to create a self-signed certificate if the keystore cannot be found.

Alias: SSLCREATECERT, SSLCREATESELFSIGNEDCERTIFICATE

LIBNAME-options

specify how SAS processes DBMS objects. Some LIBNAME options can enhance performance, and others determine locking or naming behavior. The following table describes the LIBNAME options for SAS/ACCESS Interface to SAP HANA with the applicable default values. This table also identifies LIBNAME options that are valid in the CONNECT statement in the SQL procedure. For details, see LIBNAME Options for Relational Databases.

SAS/ACCESS LIBNAME Options for SAP HANA

Option

Default Value

Valid in CONNECT

ACCESS=

none

AUTHDOMAIN=

none

AUTOCOMMIT=

NO

CHAR_AS_NCHAR=

NO

CONNECTION=

SHAREDREAD

CONNECTION_GROUP=

none

CONOPTS=

none

DBCLIENT_MAX_BYTES=

3

DBCOMMIT=

1000 (when inserting rows), 0 (when updating rows)

DBCONINIT=

none

DBCONTERM=

none

DBCREATE_TABLE_OPTS=

none

DBGEN_NAME=

DBMS

DBINDEX=

NO

DBLIBINIT=

none

DBLIBTERM=

none

DBMAX_TEXT=

1024

DBMSTEMP=

NO

DBNULLKEYS=

YES

DBNULLWHERE=

YES

DBPROMPT=

NO

DBSASLABEL=

COMPAT

DBSERVER_MAX_BYTES=

1

DBSLICEPARM=

THREADED_APPS,2 or THREADED_APPS,3

DEFER=

NO

DELETE_MULT_ROWS=

NO

DIRECT_EXE=

none

DIRECT_SQL=

YES

IGNORE_READ_ONLY_COLUMNS=

NO

INSERTBUFF=

1

LOGIN_TIMEOUT=

0

MULTI_DATASRC_OPT=

NONE

PARMDEFAULT=

none

PARMSTRING=

none

PRESERVE_COL_NAMES=

NO (see Naming Conventions for SAP HANA)

PRESERVE_TAB_NAMES=

NO (see Naming Conventions for SAP HANA)

QUERY_TIMEOUT=

0

QUOTE_CHAR=

none

READ_LOCK_TYPE=

ROW

READBUFF=

0

REREAD_EXPOSURE=

NO

SCHEMA=

none

SPOOL=

YES

SQL_FUNCTIONS=

none

SQL_FUNCTIONS_COPY=

none

SQLGENERATION=

none

STRINGDATES=

NO

SUB_CHAR=

none

TABLE_TYPE=

none

TRACE=

NO

TRACEFILE=

none

UPDATE_LOCK_TYPE=

ROW

UPDATE_MULT_ROWS=

NO

USE_ODBC_CL=

NO

UTILCONN_TRANSIENT=

NO

SAP HANA LIBNAME Statement Examples

In this example, SERVER=, DATABASE=, USER=, and PASSWORD= are connection options. No DSN style is specified. This is the default method, which is recommended.

libname A1 saphana server=mysrv1 
   port=30015 user=myusr1 password='mypwd1';

This example requires that you specify a DSN style.

libname B1 saphana dsn=hnatest user=myusr1 password=mypwd1;

Here is an example of the LIBNAME statement using the PARMSTRING= option:

libname a saphana user=userid password=xxxx server=server-name 
instance=02 preserve_tab_names=yes parmstring="parm_price=30" 
preserve_col_names=yes;
Last updated: February 3, 2026