
Sap Hana Cli
- 347 installs
- 399 repo stars
- Updated August 4, 2026
- secondsky/sap-skills
Administer HANA tenants from the terminal—run SQL, manage users, inspect schemas, troubleshoot performance, and automate routine DBA tasks on cloud or on-prem instances.
About
sap-hana-cli documents SAP HANA command-line administration: connecting to tenants, executing SQL, managing users and schemas, scripting maintenance, and troubleshooting performance for cloud and on-prem HANA workloads.
- hdbsql and HANA CLI commands
- Tenant connection and auth
- Schema and object inspection
- Scripted maintenance tasks
- Performance and log troubleshooting
Sap Hana Cli by the numbers
- 347 all-time installs (skills.sh)
- +37 installs in the week ending Jul 27, 2026 (Skillselion tracking)
- Ranked #161 of 550 CLI & Terminal skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/secondsky/sap-skills --skill sap-hana-cliAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 347 |
|---|---|
| repo stars | ★ 399 |
| Last updated | August 4, 2026 |
| Repository | secondsky/sap-skills ↗ |
What it does
Administer HANA tenants from the terminal—run SQL, manage users, inspect schemas, troubleshoot performance, and automate routine DBA tasks on cloud or on-prem instances.
Files
SAP HANA Developer CLI (hana-cli)
Related Skills
- sap-cap-capire: Use for CAP database development, HDI container management, and CDS syntax comparison
- sap-btp-cloud-platform: Use for HANA Cloud operations, BTP integration, and cloud instance management
- sap-abap-cds: Use for comparing CDS syntax between CAP and ABAP or understanding HANA CDS features
- sap-datasphere: Use when working with SAP Datasphere integration or data warehousing scenarios
- sap-dependency-security: Use for secure dependency upgrades, exact MCP server pins, npm package hardening, lockfile linting, and cooldown policy when projects include hana-cli dependencies
A developer-centric command-line interface for SAP HANA database development, particularly useful in non-SAP tooling environments like VS Code.
Repository: https://github.com/SAP-samples/hana-developer-cli-tool-example npm Package: https://www.npmjs.com/package/hana-cli Current Version: 3.202405.1 (April 2024) Node.js Requirement: ≥20.19.0
---
Table of Contents
- Quick Start
- Core Command Categories
- Output Formats
- Connection Configuration
- Common Workflows
- Bundled Resources
Quick Start
Installation
# Install globally via npm (recommended)
npm install -g hana-cli
# Verify installation
hana-cli versionFirst Connection
# Interactive connection setup
hana-cli connect
# Or specify connection directly
hana-cli connect -n "hostname:port" -u DBUSER -p PASSWORD --save
# Using service key (HANA Cloud)
hana-cli connectViaServiceKey---
MCP Integration (AI-Driven Database Operations)
Overview
The hana-mcp-server integration enables natural language database operations through Claude's Model Context Protocol. Use conversational queries alongside traditional CLI commands for a complete development workflow.
Setup
The bundled MCP config pins hana-mcp-server@0.3.1. Use sap-dependency-security before changing this pin because the server receives HANA tenant connection environment variables.
1. Environment Variables
Required configuration (add to ~/.zshrc, ~/.bashrc, or project .env):
export HANA_HOST="your-hana-host.hanacloud.ondemand.com"
export HANA_PORT="443"
export HANA_USER="DBADMIN"
export HANA_PASSWORD="your-password"
export HANA_ENCRYPT="true" # Optional, defaults to true
export HANA_DATABASE="" # Optional, for MDC tenant
export HANA_CONNECTION_TYPE="single-container" # Optional2. Connection Types
- single-container (default): Standard HANA databases
- mdc-system: Multi-tenant system database
- mdc-tenant: Specific tenant in multi-tenant environment
When to Use: CLI vs MCP
| Scenario | Recommended Tool | Why |
|---|---|---|
| Exploratory queries, ad-hoc analysis | MCP | Natural language, no syntax needed |
| Automation scripts, CI/CD pipelines | CLI | Scriptable, consistent output |
| Learning database structure | MCP | Conversational discovery |
| Generating CDS/EDMX/OpenAPI output | CLI | Supports 17+ formats |
| Complex multi-step workflows | CLI | Fine-grained control |
| Quick data sampling and inspection | MCP | Faster for one-off queries |
Example Natural Language Queries
Schema & Table Discovery
- "Show me all schemas in this HANA database"
- "List all tables in the SYSTEM schema"
- "What tables exist in the MY_APP schema?"
- "Show me all views in the PUBLIC schema"
Table Structure & Metadata
- "Describe the structure of the USERS table"
- "What columns does the ORDERS table have?"
- "Show me the data types for MY_TABLE"
- "What is the primary key of the CUSTOMERS table?"
Data Sampling & Inspection
- "Sample 5 rows from the PRODUCTS table"
- "Show me the first 10 records from SALES_DATA"
- "Get sample data from ORDER_ITEMS table"
- "Display a few rows from MY_TABLE"
Query Execution
- "How many rows are in the CUSTOMERS table?"
- "Show me distinct values in the STATUS column of ORDERS"
- "What is the maximum value in the PRICE column of PRODUCTS?"
- "Find all records in USERS where country is 'USA'"
System Performance & Monitoring
- "Check the HANA database status"
- "Show me system performance metrics"
- "What is the current database version?"
MCP Tools Available
The hana-mcp-server provides these MCP tools:
list_schemas: Enumerate all schemaslist_tables: Show tables in a schemadescribe_table: Get table structure and metadataquery: Execute SQL queries from natural languagesample_data: Retrieve sample rowssystem_info: Database status and performance
Example: MCP + CLI Workflow
# 1. Use MCP to explore (natural language)
"Show me all tables in the PRODUCTS schema"
# 2. Use MCP to understand structure
"Describe the PRODUCTS.INVENTORY table"
# 3. Use CLI for format conversion (precise output)
hana-cli inspectTable -t INVENTORY -s PRODUCTS -o cds
# 4. Use CLI for HDI operations
hana-cli createContainer -c MY_CONTAINER---
Core Command Categories
Database Object Inspection
| Command | Aliases | Purpose |
|---|---|---|
inspectTable | it, table | Inspect table structure |
inspectView | - | Inspect view definition |
inspectProcedure | - | Inspect stored procedure |
inspectFunction | - | Inspect function definition |
tables | - | List all tables in schema |
views | - | List all views in schema |
procedures | - | List stored procedures |
functions | - | List functions |
Query Execution
| Command | Aliases | Purpose |
|---|---|---|
querySimple | qs | Execute SQL query |
callProcedure | cp | Execute stored procedure |
hdbsql | - | Direct SQL execution |
HDI Container Management
| Command | Aliases | Purpose |
|---|---|---|
containers | cont | List HDI containers |
createContainer | - | Create new container |
dropContainer | - | Remove container |
activateHDI | - | Enable HDI service |
adminHDI | - | Administer HDI privileges |
Cloud & BTP Operations
| Command | Aliases | Purpose |
|---|---|---|
hanaCloudInstances | - | List HANA Cloud instances |
hanaCloudStart | - | Start cloud instance |
hanaCloudStop | - | Stop cloud instance |
btp | - | Configure BTP CLI |
btpInfo | - | Display BTP target info |
---
Output Formats
The --output / -o option supports 17+ formats:
| Format | Use Case |
|---|---|
tbl | Human-readable table (default) |
json | JSON data |
yaml | YAML format |
csv | CSV export |
excel | Excel file |
cds | CAP CDS definitions |
hdbcds | HANA CDS format |
hdbtable | HDB Table definitions |
sql | SQL DDL statements |
edmx | OData EDMX metadata |
openapi | OpenAPI/Swagger spec |
graphql | GraphQL schema |
---
Connection Configuration
Connection credentials are searched in priority order:
1. default-env-admin.json (with --admin flag) 2. .cdsrc-private.json (via cds bind) 3. .env file with VCAP_SERVICES 4. File specified via --conn parameter 5. default-env.json in current/parent directories 6. ~/.hana-cli/default.json
For connection templates, see templates/default-env.json.
---
Common Workflows
Inspect and Convert Table to CDS
# Inspect table structure
hana-cli inspectTable -s MYSCHEMA -t MYTABLE
# Convert to CDS format
hana-cli inspectTable -s MYSCHEMA -t MYTABLE -o cdsMass Convert Schema Objects
# Convert all objects in schema to CDS
hana-cli massConvert -s MYSCHEMAExecute Query with Export
# Run query and export to JSON
hana-cli querySimple -q "SELECT * FROM MYTABLE" -o json
# Export to Excel file
hana-cli querySimple -q "SELECT * FROM MYTABLE" -o excel -f ./output -n reportManage HDI Containers
# List all containers
hana-cli containers
# Create new container
hana-cli createContainer -c MY_CONTAINER -g MY_GROUP
# Create container users
hana-cli createContainerUsers -c MY_CONTAINER---
UI Commands
Many commands have browser-based UI alternatives (suffix UI):
tablesUI- Browse tables visuallycontainersUI- Manage containers in browsermassConvertUI- Visual mass conversionquerySimpleUI- Query builder interfacesystemInfoUI- System dashboard
---
Key Features
- Multi-database support: HANA, PostgreSQL, SQLite backends
- Format conversion: 17+ output formats including CDS, EDMX, OpenAPI
- HDI management: Full container lifecycle management
- Cloud integration: SAP BTP CLI and HANA Cloud support
- Interactive prompts: Missing parameters prompted automatically
- Service key auth: Secure cloud authentication
---
Detailed References
For comprehensive documentation:
- All 91 Commands: See
references/command-reference.md - Connection & Security: See
references/connection-security.md - HDI Management: See
references/hdi-management.md - Output Formats: See
references/output-formats.md - Cloud Operations: See
references/cloud-operations.md - Database Inspection: See
references/db-inspection.md - Mass Operations: See
references/mass-operations.md - System Administration: See
references/system-admin.md - Web UI Interface: See
references/web-ui.md - Troubleshooting Guide: See
references/troubleshooting.md - Development Environment: See
references/development-environment.md - ABAP Programming Patterns: See
references/abap-programming.md
---
Troubleshooting
Connection Issues
# Check current connection status
hana-cli status
# Test with explicit credentials
hana-cli connect -n "host:443" -u USER -p PASS --encrypt true
# Use SSL trust store
hana-cli connect --trustStore /path/to/certificate.pemPermission Errors
# Diagnose privilege errors
hana-cli privilegeError
# View current user info
hana-cli inspectUserVersion Compatibility
- Node.js: Requires ≥20.19.0
- @sap/cds: Uses 9.4.4
- @sap/cds-dk: Requires ≥8.9 for cds bind
---
Bundled Resources
Reference Documentation
references/command-reference.md- Complete command reference with all optionsreferences/abap-programming.md- ABAP-specific programming patternsreferences/development-environment.md- Development setup and environment guidancereferences/connection-security.md- Secure connection and credential handlingreferences/troubleshooting.md- Common errors and recovery steps
Templates
templates/default-env.json- Local connection template for CAP-style bindingstemplates/cdsrc-private.json- CAP private configuration template
Resources
- GitHub: https://github.com/SAP-samples/hana-developer-cli-tool-example
- Intro Video: https://youtu.be/dvVQfi9Qgog
- Cloud Shells Demo: https://youtu.be/L7QyVLvAIIQ
- SAP HANA Cloud: https://help.sap.com/docs/hana-cloud
- SAP CAP: https://cap.cloud.sap/docs/
---
Last Updated: 2025-11-26 | Version: 1.1.0
SAP HANA CLI Skill
A comprehensive Claude Code skill for the SAP HANA Developer Command Line Interface (hana-cli).
---
Overview
This skill provides guidance for using the hana-cli npm package - a developer-centric CLI tool for SAP HANA database development. It covers all 91 commands, 17+ output formats, HDI container management, and cloud operations.
Source Repository: https://github.com/SAP-samples/hana-developer-cli-tool-example
---
Capability Index
| Capability | Status |
|---|---|
| Commands | 2: /hana-connect-check, /hana-inspect-object |
| Agents | 1: hana-database-advisor |
| Hooks | No |
| MCP | Yes: .mcp.json |
| LSP | No |
| Source Freshness | last_verified: 2025-11-26; hana-cli and hana-client package evidence tracked in audit report. |
| Verification | npm run validate; live database checks pending unless a safe connection is provided. |
Keywords
Tool & Package Names
- hana-cli
- sap-hana-cli
- hana developer cli
- hana command line
- hana developer command line interface
- npm hana-cli
- hana-cli install
- hana-cli commands
Installation & Setup
- npm install hana-cli
- hana-cli install
- hana-cli setup
- hana-cli connect
- hana-cli connection
- hana-cli default-env
- hana-cli default-env.json
- hana-cli credentials
- hana-cli service key
- connectViaServiceKey
Database Operations
- hana-cli tables
- hana-cli views
- hana-cli procedures
- hana-cli functions
- hana-cli indexes
- hana-cli schemas
- hana-cli sequences
- hana-cli synonyms
- hana-cli triggers
- hana-cli objects
- hana-cli dataTypes
Inspection Commands
- hana-cli inspectTable
- hana-cli inspectView
- hana-cli inspectProcedure
- hana-cli inspectFunction
- hana-cli inspectIndex
- hana-cli inspectTrigger
- hana-cli inspectUser
- hana inspect table
- table metadata hana
- view definition hana
Query Execution
- hana-cli querySimple
- hana-cli callProcedure
- hana-cli hdbsql
- hana sql query
- execute sql hana
- call procedure hana
- hana stored procedure
HDI Container Management
- hana-cli containers
- hana-cli createContainer
- hana-cli dropContainer
- hana-cli activateHDI
- hana-cli adminHDI
- hana-cli createContainerUsers
- hdi container
- hdi container management
- hana deployment infrastructure
- hdi activation
- hdi admin
Format Conversion
- hana to cds
- hana to json
- hana to yaml
- hana to edmx
- hana to openapi
- hana to graphql
- hana to sql
- hana to hdbtable
- hana-cli massConvert
- convert table to cds
- table to openapi
- database to cds
Output Formats
- hana-cli output json
- hana-cli output cds
- hana-cli output edmx
- hana-cli output yaml
- hana-cli output csv
- hana-cli output excel
- hana-cli output graphql
- hana-cli output openapi
Cloud & BTP
- hana cloud cli
- sap hana cloud
- hana-cli hanaCloudInstances
- hana-cli hanaCloudStart
- hana-cli hanaCloudStop
- hana-cli btp
- btp cli hana
- hana cloud start stop
- hana cloud instance management
Security & Connection
- hana-cli ssl
- hana-cli encrypt
- hana-cli trustStore
- hana connection security
- hana ssl connection
- cds bind hana
- .cdsrc-private.json
- hana service key
System Information
- hana-cli systemInfo
- hana-cli hostInformation
- hana-cli version
- hana-cli status
- hana system information
- hana database version
Troubleshooting
- hana-cli error
- hana-cli privilege error
- hana-cli connection failed
- hana cli not working
- hana-cli troubleshoot
- hana permission error
Development Tools
- hana-cli cds
- hana-cli openDBExplorer
- hana-cli openBAS
- hana database explorer
- business application studio hana
Mass Operations
- hana-cli massConvert
- hana-cli massRename
- hana-cli massUsers
- batch convert hana
- mass convert cds
Technologies
- SAP HANA
- SAP HANA Cloud
- SAP BTP
- SAP CAP
- Cloud Foundry
- HDI
- HANA Deployment Infrastructure
- OData
- GraphQL
- CDS
- Cloud Application Programming Model
---
Skill Structure
sap-hana-cli/
├── SKILL.md # Main skill instructions
├── README.md # This file (keywords)
├── references/
│ ├── command-reference.md # All 91 commands
│ ├── connection-security.md # Connection & security
│ ├── hdi-management.md # HDI container ops
│ ├── output-formats.md # 17+ formats
│ └── cloud-operations.md # BTP & cloud commands
└── templates/
├── default-env.json # Connection template
└── cdsrc-private.json # CDS bind template---
When to Use This Skill
This skill activates when users:
- Ask about hana-cli installation or setup
- Need to connect to SAP HANA databases
- Want to inspect database objects (tables, views, procedures)
- Need to convert metadata to CDS, EDMX, OpenAPI formats
- Work with HDI containers
- Manage SAP HANA Cloud instances
- Execute SQL queries via CLI
- Troubleshoot hana-cli issues
- Need output format options
---
Version Information
| Component | Version |
|---|---|
| hana-cli | 3.202405.1 |
| Node.js Required | ≥20.19.0 |
| @sap/cds | 9.4.4 |
| Skill Version | 1.1.0 |
---
Resources
- GitHub Repository: https://github.com/SAP-samples/hana-developer-cli-tool-example
- npm Package: https://www.npmjs.com/package/hana-cli
- Intro Video: https://youtu.be/dvVQfi9Qgog
- Cloud Shell Demo: https://youtu.be/L7QyVLvAIIQ
- SAP HANA Cloud: https://help.sap.com/docs/hana-cloud
- SAP CAP: https://cap.cloud.sap/docs/
---
License
GPL-3.0 License
---
Last Updated: 2025-11-26
SAP ABAP Programming Reference
Source: https://codezentrale.de/category/sap/sap-abap/ Language: Translated from German
This reference covers ABAP programming patterns relevant to SAP HANA development.
---
Table of Contents
1. SQL Operations 2. Internal Tables 3. String Operations 4. JSON Processing 5. XML Processing 6. Regular Expressions 7. Exception Handling 8. Performance Optimization
---
SQL Operations
Open SQL
Common Table Expressions (CTE)
WITH
+cte1 AS ( SELECT * FROM table1 WHERE condition ),
+cte2 AS ( SELECT * FROM +cte1 WHERE condition2 )
SELECT * FROM +cte2 INTO TABLE @DATA(lt_result).String Aggregation
SELECT STRING_AGG( field, ',' ) AS aggregated
FROM table
INTO @DATA(lv_result).Global Temporary Tables (GTT)
" Use GTT for intermediate data storagePerformance Comparison
| Method | Performance |
|---|---|
| RANGE clause | ~0.086 seconds |
| FOR ALL ENTRIES | ~0.073 seconds |
| JOIN | ~0.012 seconds (fastest) |
Best Practice: Use JOINs instead of FOR ALL ENTRIES when possible.
AMDP (ABAP Managed Database Procedures)
Convert RANGES to WHERE clause for AMDP:
" Using cl_shdb_seltab
DATA(lv_where) = cl_shdb_seltab=>combine_seltabs(
it_named_seltabs = VALUE #(
( name = 'FIELD' dref = REF #( lr_range ) )
)
)->sql_where_condition( ).---
Internal Tables
TABLE_LINE Pseudo-Component
" Access complete row without structure
DATA(lv_vbeln) = it_vbeln[ table_line = '2345678901' ].REDUCE Operator
" Sum values
DATA(lv_sum) = REDUCE decfloat34(
INIT sum = CONV decfloat34( 0 )
FOR wa IN it_costs
NEXT sum = sum + wa-amount ).OPTIONAL Clause
" Avoid exceptions for missing entries
DATA(ls_person) = VALUE #( it_persons[ name = 'John' ] OPTIONAL ).DEFAULT VALUE
" Provide fallback value
DATA(ls_person) = VALUE #(
it_persons[ name = 'John' ]
DEFAULT VALUE #( name = '<empty>' age = -1 )
).BASE Operator
" Prepend existing data
it_result = VALUE #( BASE it_existing ( field = 'new' ) ).Line Index
" Get index without exceptions
DATA(lv_idx) = line_index( itab[ col = '123' ] ).Search Operations
" Case-insensitive search
FIND 'pattern' IN TABLE it_data IGNORING CASE.
" All occurrences
FIND ALL OCCURRENCES OF 'pattern' IN it_data
RESULTS DATA(lt_results).---
String Operations
Substring Extraction
" Offset and length syntax
DATA(lv_first) = CONV string( lv_string+0(1) ).
DATA(lv_middle) = CONV string( lv_string+5(3) ).Transliteration
" Convert special characters
CALL FUNCTION 'SCP_REPLACE_STRANGE_CHARS'
EXPORTING
intext = lv_input
IMPORTING
outtext = lv_output.
" Result: ÄÖÜ → AeOeUeCodepage Conversion
" SAP codepage to HTTP encoding
DATA(lv_encoding) = cl_abap_codepage=>sap_codepage(
http_encoding = 'UTF-8' ).Pattern Matching (CP Operator)
" Wildcard matching
IF lv_string CP '*-*'. " Contains dash
IF lv_string CP '+++*'. " Three+ charactersMessage Text Splitting
" Distribute text across message fields
cl_message_helper=>set_msg_vars_for_clike(
EXPORTING i_text = lv_long_text ).
" Access via sy-msgv1, sy-msgv2, sy-msgv3, sy-msgv4---
JSON Processing
ABAP to JSON
" Using xco_cp_json (modern)
DATA(lv_json) = xco_cp_json=>data->from_abap( ls_data )->to_string( ).
" Using /ui2/cl_json
DATA(lv_json) = /ui2/cl_json=>serialize(
data = ls_data
pretty_name = /ui2/cl_json=>pretty_mode-camel_case ).JSON to ABAP
" Using xco_cp_json
xco_cp_json=>data->from_string( lv_json )->apply(
VALUE #( ( xco_cp_json=>transformation->boolean_to_abap_bool )
( xco_cp_json=>transformation->pascal_case_to_underscore ) )
)->write_to( REF #( ls_data ) ).
" Using /ui2/cl_json
/ui2/cl_json=>deserialize(
EXPORTING json = lv_json
CHANGING data = ls_data ).Internal Table to JSON
" Using transformation
CALL TRANSFORMATION id
SOURCE values = it_data
RESULT XML DATA(lv_json).---
XML Processing
XML to Internal Table
" Using cl_xml_document
DATA(lo_xml) = cl_xml_document=>create( ).
lo_xml->import_from_file( lv_filename ).
CALL FUNCTION 'SMUM_XML_PARSE'
EXPORTING
xml_input = lo_xml->get_document_xml_string( )
TABLES
return = lt_return
xml_table = lt_xml_data.Display XML in Browser
cl_soap_xml_helper=>xml_show(
xml_xstring = lv_xml_xstring ).ABAP to XML
DATA(lv_xml) = cl_proxy_xml_transform=>abap_to_xml_xstring(
abap_data = ls_structure ).---
Regular Expressions
Replace Non-Alphanumeric
REPLACE ALL OCCURRENCES OF REGEX '[^\w]+' IN lv_str WITH '_'.Using cl_abap_matcher
DATA(lo_matcher) = cl_abap_matcher=>create(
pattern = '<placeholder>'
text = lv_text
ignore_case = abap_true ).
IF lo_matcher->replace_all( ' and ' ) > 0.
DATA(lv_result) = lo_matcher->text.
ENDIF.Extract Submatches
DATA(lo_matcher) = cl_abap_matcher=>create(
pattern = '^/category/([0-9]+)/item/([0-9]+)$'
text = '/category/12345/item/12' ).
IF lo_matcher->match( ).
DATA(lv_category) = lo_matcher->get_submatch( 1 ). " 12345
DATA(lv_item) = lo_matcher->get_submatch( 2 ). " 12
ENDIF.Remove HTML Tags
DATA(lo_matcher) = cl_abap_matcher=>create(
pattern = '<([!A-Za-z][A-Za-z0-9]*)|</([A-Za-z][A-Za-z0-9]*)>'
text = lv_html ).
lo_matcher->replace_all( '' ).Common Patterns
| Pattern | Purpose |
|---|---|
[^\w]+ | Non-alphanumeric characters |
\s | Whitespace |
[0-9] | Digits |
| `^(AA\ | BB).*$` |
\d{5} | German postal code |
---
Exception Handling
TRY...CATCH Block
TRY.
" Risky operation
DATA(lv_result) = 1 / 0.
CATCH cx_sy_zerodivide INTO DATA(lx_error).
" Handle exception
DATA(lv_msg) = lx_error->get_text( ).
ENDTRY.Custom Exception Class
CLASS lcx_custom_error DEFINITION
INHERITING FROM cx_static_check.
PUBLIC SECTION.
DATA mv_custom_field TYPE string.
METHODS constructor
IMPORTING
iv_custom_field TYPE string OPTIONAL.
ENDCLASS.
" Raising
RAISE EXCEPTION TYPE lcx_custom_error
EXPORTING iv_custom_field = 'Error details'.Using CX_T100_MSG
CLASS lcx_message DEFINITION
INHERITING FROM cx_t100_msg.
PUBLIC SECTION.
CONSTANTS:
BEGIN OF error_occurred,
msgid TYPE symsgid VALUE 'ZMSG',
msgno TYPE symsgno VALUE '001',
attr1 TYPE scx_attrname VALUE 'MV_ATTR1',
END OF error_occurred.
ENDCLASS.---
Performance Optimization
Field Symbols vs. References
" Faster: Field symbols
LOOP AT it_data ASSIGNING FIELD-SYMBOL(<ls_data>).
<ls_data>-field = 'value'.
ENDLOOP.
" Slower: References
LOOP AT it_data REFERENCE INTO DATA(lr_data).
lr_data->field = 'value'.
ENDLOOP.COLLECT for Deduplication
" Fastest approach - uses internal hash table
COLLECT ls_line INTO it_aggregated.Table Copy Efficiency
" Most efficient: Direct assignment
it_target = it_source.
" Also efficient: CORRESPONDING
it_target = CORRESPONDING #( it_source ).SQL Best Practices
1. Use JOINs instead of FOR ALL ENTRIES 2. Use WHERE conditions early 3. Limit result sets with UP TO n ROWS 4. Use indexes appropriately 5. Avoid SELECT * when possible
---
Useful Classes Reference
| Class | Purpose |
|---|---|
cl_abap_matcher | Regular expressions |
cl_abap_codepage | Codepage conversion |
/ui2/cl_json | JSON serialization |
xco_cp_json | Modern JSON handling |
cl_xml_document | XML processing |
cl_salv_table | ALV display |
cl_gui_alv_grid | ALV grid control |
cl_abap_typedescr | Runtime type info |
cl_shdb_seltab | RANGES to WHERE |
---
Source: [https://codezentrale.de/category/sap/sap-abap/](https://codezentrale.de/category/sap/sap-abap/*)
SAP HANA CLI - Cloud & BTP Operations
Source: https://github.com/SAP-samples/hana-developer-cli-tool-example
Commands for managing SAP HANA Cloud instances and SAP BTP integration.
---
BTP CLI Integration
The hana-cli integrates with SAP BTP CLI for cloud resource management.
Configure BTP Target
# Configure BTP CLI targeting
hana-cli btpThis sets up the connection to your BTP global account.
View BTP Information
# Display current BTP target
hana-cli btpInfoList BTP Subscriptions
# List subscribed services
hana-cli btpSubs---
HANA Cloud Instance Management
List All HANA Cloud Instances
hana-cli hanaCloudInstancesStart HANA Cloud Instance
# Start a stopped instance
hana-cli hanaCloudStart [instance]Use Cases:
- Resume development after break
- Scheduled startup
- Cost management (stop during off-hours)
Stop HANA Cloud Instance
# Stop running instance
hana-cli hanaCloudStop [instance]Note: Stopping instances helps reduce costs. Trial instances auto-stop after inactivity.
---
Cloud Instance Types
HDI Instances
# List Cloud HDI instances
hana-cli hanaCloudHDIInstances
# UI version
hana-cli hanaCloudHDIInstancesUISchema Instances
# List Cloud schema instances
hana-cli hanaCloudSchemaInstances
# UI version
hana-cli hanaCloudSchemaInstancesUISBSS Instances
Service Broker Secure Store instances.
# List Cloud SBSS instances
hana-cli hanaCloudSBSSInstances
# UI version
hana-cli hanaCloudSBSSInstancesUISecure Store Instances
# List Cloud secure store instances
hana-cli hanaCloudSecureStoreInstances
# UI version
hana-cli hanaCloudSecureStoreInstancesUIUPS Instances
User-Provided Service instances.
# List Cloud UPS instances
hana-cli hanaCloudUPSInstances
# UI version
hana-cli hanaCloudUPSInstancesUI---
Cloud Connection
Using Service Keys
Connect to HANA Cloud using service keys:
# Interactive service key connection
hana-cli connectViaServiceKeyCloud Connection File
{
"VCAP_SERVICES": {
"hana": [{
"name": "hana-cloud",
"credentials": {
"host": "xxxxxxxx.hana.trial-eu10.hanacloud.ondemand.com",
"port": "443",
"user": "DBADMIN",
"password": "SecurePass123!",
"encrypt": true,
"sslValidateCertificate": true
}
}]
}
}SSL Requirements
HANA Cloud requires SSL:
hana-cli connect \
-n "instance.hanacloud.ondemand.com:443" \
-u DBADMIN \
--encrypt true---
Cloud Shell Compatibility
The hana-cli works in cloud-based development environments:
SAP Business Application Studio
# Open BAS in browser
hana-cli openBASGoogle Cloud Shell
Full compatibility with GCP Cloud Shell.
AWS Cloud9
Full compatibility with AWS Cloud9.
Video Demo
Cloud shell usage: https://youtu.be/L7QyVLvAIIQ
---
Cloud Workflows
Development Instance Setup
1. Create instance in SAP BTP Cockpit
2. Generate service key
3. Connect via hana-cli:
hana-cli connectViaServiceKey4. Verify connection:
hana-cli status
hana-cli systemInfoCost Optimization
1. Check instance status:
hana-cli hanaCloudInstances2. Stop when not needed:
hana-cli hanaCloudStop myinstance3. Start when needed:
hana-cli hanaCloudStart myinstanceHDI Container in Cloud
1. List cloud HDI instances:
hana-cli hanaCloudHDIInstances2. Create container:
hana-cli createContainer MY_APP3. Create users:
hana-cli createContainerUsers MY_APP---
CDS Bind for Cloud
Use CDS binding for secure cloud credentials:
Setup
# In your CAP project directory
cds bind --to hana --for hybrid.cdsrc-private.json
{
"requires": {
"db": {
"kind": "hana",
"binding": {
"type": "cf",
"apiEndpoint": "https://api.cf.eu10.hana.ondemand.com",
"org": "my-org",
"space": "dev",
"instance": "hana-hdi"
}
}
}
}Benefits
- No local credential storage
- Dynamic credential lookup
- Works with rotated credentials
- Most secure option
Tradeoff
Each command execution includes credential lookup, adding slight latency.
---
Troubleshooting Cloud Connections
Instance Not Responding
# Check if stopped
hana-cli hanaCloudInstances
# Start if needed
hana-cli hanaCloudStart myinstanceSSL Certificate Issues
# Ensure encryption enabled
hana-cli connect --encrypt true
# Custom trust store if needed
hana-cli connect --trustStore /path/to/DigiCertGlobalRootCA.crtBTP Target Issues
# Reconfigure BTP
hana-cli btp
# Verify target
hana-cli btpInfo---
Cloud Resources
- SAP HANA Cloud: https://help.sap.com/docs/hana-cloud
- SAP BTP: https://help.sap.com/docs/btp
- HANA Cloud Getting Started: https://developers.sap.com/group.hana-cloud-get-started-1-trial.html
---
Reference: [https://github.com/SAP-samples/hana-developer-cli-tool-example](https://github.com/SAP-samples/hana-developer-cli-tool-example*)
SAP HANA CLI - Complete Command Reference
Source: https://github.com/SAP-samples/hana-developer-cli-tool-example Total Commands: 91
---
Table of Contents
1. Database Object Commands 2. Inspection Commands 3. Connection Commands 4. HDI Container Commands 5. Query & Execution Commands 6. Mass Operation Commands 7. Cloud & BTP Commands 8. User & Role Commands 9. System Information Commands 10. Development Commands 11. Monitoring Commands 12. Documentation Commands
---
Database Object Commands
tables
List tables in schema.
hana-cli tables [schema]Options:
| Option | Alias | Type | Default | Description |
|---|---|---|---|---|
| schema | s | string | CURRENT_SCHEMA | Target schema |
| limit | l | number | 200 | Max results |
UI Alternative: tablesUI
views
List views in schema.
hana-cli views [schema]procedures
List stored procedures.
hana-cli procedures [schema]functions / functionsUI
List database functions.
hana-cli functions [schema]indexes / indexesUI
List database indexes.
hana-cli indexes [schema] [table]sequences
List sequences.
hana-cli sequences [schema]synonyms
List synonyms.
hana-cli synonyms [schema]triggers
List database triggers.
hana-cli triggers [schema]schemas / schemasUI
List available schemas.
hana-cli schemasdataTypes / dataTypesUI
Display HANA data type specifications.
hana-cli dataTypesobjects
List all database objects.
hana-cli objects [schema]libraries
List database libraries.
hana-cli libraries [schema]---
Inspection Commands
inspectTable
Inspect table structure with format conversion.
Aliases: it, table, insTbl, inspecttable, inspectable
hana-cli inspectTable [schema] [table]Options:
| Option | Alias | Type | Default | Description |
|---|---|---|---|---|
| table | t | string | required | Table name |
| schema | s | string | CURRENT_SCHEMA | Schema name |
| output | o | string | tbl | Output format |
| useHanaTypes | hana | boolean | false | Use HANA types |
| useQuoted | q | boolean | false | Quoted identifiers |
| useExists | exists | boolean | true | Check existence |
Output Formats: tbl, sql, sqlite, postgres, cds, json, yaml, cdl, hdbcds, hdbtable, hdbmigrationtable, jsdoc, graphql, edmx, annos, edm, swgr, openapi
UI Alternative: inspectTableUI
inspectView
Inspect view definition.
hana-cli inspectView [schema] [view]inspectProcedure
Inspect stored procedure.
hana-cli inspectProcedure [schema] [procedure]inspectFunction
Inspect function definition.
hana-cli inspectFunction [schema] [function]inspectIndex
Inspect index structure.
hana-cli inspectIndex [schema] [index]inspectTrigger
Inspect trigger definition.
hana-cli inspectTrigger [schema] [trigger]inspectUser
Inspect database user.
hana-cli inspectUser [user]inspectLibrary
Inspect database library.
hana-cli inspectLibrary [schema] [library]inspectLibMember
Inspect library member.
hana-cli inspectLibMember [schema] [library] [member]inspectJWT
Inspect and decode JWT token.
hana-cli inspectJWT [token]---
Connection Commands
connect
Establish and save database connection.
Aliases: c, login
hana-cli connect [user] [password]Options:
| Option | Alias | Type | Default | Description |
|---|---|---|---|---|
| connection | n | string | - | host:port |
| user | u | string | - | Database user |
| password | p | string | - | Password (masked) |
| userstorekey | U | string | - | User store key |
| save | s | boolean | true | Save credentials |
| encrypt | e | boolean | - | Enable SSL |
| trustStore | t | string | - | SSL certificate path |
connectViaServiceKey
Connect using BTP service key.
hana-cli connectViaServiceKeystatus
Display current connection status.
hana-cli statuscertificates
List system certificates.
hana-cli certificates---
HDI Container Commands
activateHDI
Enable HDI service for tenant.
hana-cli activateHDI [tenant]adminHDI
Create/assign HDI admin privileges.
hana-cli adminHDI [user]adminHDIGroup
Add HDI group administrator.
hana-cli adminHDIGroup [group] [user]containers
List HDI containers.
Aliases: cont, listContainers
hana-cli containers [containerGroup] [container]Options:
| Option | Alias | Type | Default | Description |
|---|---|---|---|---|
| container | c | string | * | Container filter |
| containerGroup | g | string | * | Group filter |
| limit | l | number | 200 | Max results |
UI Alternative: containersUI
createContainer
Create new HDI container.
hana-cli createContainer [container] [group]createContainerUsers
Create container access users.
hana-cli createContainerUsers [container]dropContainer
Remove HDI container.
hana-cli dropContainer [container]createGroup
Create container group.
hana-cli createGroup [group]dropGroup
Remove container group.
hana-cli dropGroup [group]---
Query & Execution Commands
querySimple
Execute SQL query with flexible output.
Aliases: qs, querysimple
hana-cli querySimple [query]Options:
| Option | Alias | Type | Default | Description |
|---|---|---|---|---|
| query | q | string | required | SQL query |
| folder | f | string | ./ | Output directory |
| filename | n | string | - | Output filename |
| output | o | string | table | Output format |
| profile | p | string | - | Connection profile |
Output Formats: table, json, excel, csv
UI Alternative: querySimpleUI
callProcedure
Execute stored procedure.
Aliases: cp, callprocedure, callProc, callSP
hana-cli callProcedure [schema] [procedure]Options:
| Option | Alias | Type | Default | Description |
|---|---|---|---|---|
| procedure | p | string | required | Procedure name |
| schema | s | string | CURRENT_SCHEMA | Schema name |
hdbsql
Direct SQL execution interface.
hana-cli hdbsql---
Mass Operation Commands
massConvert
Batch convert database objects.
Aliases: mc, massconvert, massConv
hana-cli massConvert [schema] [table] [view]UI Alternative: massConvertUI
massRename
Batch rename operations.
hana-cli massRename [schema]massUsers
Bulk user operations.
hana-cli massUsers---
Cloud & BTP Commands
btp
Configure BTP CLI targeting.
hana-cli btpbtpInfo
Display BTP target details.
hana-cli btpInfobtpSubs
List BTP subscriptions.
hana-cli btpSubshanaCloudInstances
List HANA Cloud instances.
hana-cli hanaCloudInstanceshanaCloudHDIInstances / hanaCloudHDIInstancesUI
List Cloud HDI instances.
hana-cli hanaCloudHDIInstanceshanaCloudSchemaInstances / hanaCloudSchemaInstancesUI
List Cloud schema instances.
hana-cli hanaCloudSchemaInstanceshanaCloudSBSSInstances / hanaCloudSBSSInstancesUI
List Cloud SBSS instances.
hana-cli hanaCloudSBSSInstanceshanaCloudSecureStoreInstances / hanaCloudSecureStoreInstancesUI
List Cloud secure store instances.
hana-cli hanaCloudSecureStoreInstanceshanaCloudUPSInstances / hanaCloudUPSInstancesUI
List Cloud UPS instances.
hana-cli hanaCloudUPSInstanceshanaCloudStart
Start HANA Cloud instance.
hana-cli hanaCloudStart [instance]hanaCloudStop
Stop HANA Cloud instance.
hana-cli hanaCloudStop [instance]---
User & Role Commands
users
List database users.
hana-cli usersroles
List database roles.
hana-cli rolescreateXSAAdmin
Create XSA administrator.
hana-cli createXSAAdmin [user]createJWT
Generate JWT token.
hana-cli createJWT---
System Information Commands
systemInfo / systemInfoUI
Display system information.
hana-cli systemInfohostInformation
Display host details.
hana-cli hostInformationversion
Display hana-cli version.
hana-cli versionports
List database ports.
hana-cli portsdisks
Display disk information.
hana-cli disksdataVolumes
Display data volume information.
hana-cli dataVolumesiniFiles
List INI configuration files.
hana-cli iniFilesiniContents
Display INI file contents.
hana-cli iniContents [file]---
Development Commands
cds
Convert database objects to CDS format.
hana-cli cds [schema] [object]createModule
Create development module.
hana-cli createModulecopy2DefaultEnv
Copy credentials to default-env.json.
hana-cli copy2DefaultEnvcopy2Env
Copy credentials to .env file.
hana-cli copy2Envcopy2Secrets
Copy credentials to secrets.
hana-cli copy2SecretsopenDBExplorer
Open HANA Database Explorer.
hana-cli openDBExploreropenBAS
Open Business Application Studio.
hana-cli openBAS---
Monitoring Commands
features / featuresUI
Display database features.
hana-cli featuresfeatureUsage / featureUsageUI
Display feature usage metrics.
hana-cli featureUsagetraces
List trace files.
hana-cli tracestraceContents
Display trace contents.
hana-cli traceContents [trace]privilegeError
Diagnose privilege errors.
hana-cli privilegeErrorreclaim
Reclaim database resources.
hana-cli reclaim---
Documentation Commands
changeLog / changeLogUI / openChangeLog
View release changelog.
hana-cli changeLog
hana-cli openChangeLog # Opens in browserreadMe / readMeUI / openReadMe
View documentation.
hana-cli readMe
hana-cli openReadMe # Opens in browserissue
Report issue to GitHub.
hana-cli issueUI
Open general web UI.
hana-cli UI---
Global Options
All commands support:
| Option | Alias | Description |
|---|---|---|
| --help | -h | Display help |
| --admin | - | Use admin credentials |
| --conn | - | Specify connection file |
| --profile | -p | Connection profile |
---
Reference: [https://github.com/SAP-samples/hana-developer-cli-tool-example](https://github.com/SAP-samples/hana-developer-cli-tool-example*)
SAP HANA CLI - Connection & Security Guide
Source: https://github.com/SAP-samples/hana-developer-cli-tool-example
---
Connection Credential Hierarchy
The hana-cli searches for connection credentials in this priority order:
1. default-env-admin.json (Highest Priority)
Used when --admin flag is specified.
{
"VCAP_SERVICES": {
"hana": [{
"name": "hana-admin",
"credentials": {
"host": "hostname.hanacloud.ondemand.com",
"port": "443",
"user": "DBADMIN",
"password": "AdminPassword123",
"schema": "MYSCHEMA",
"encrypt": true,
"sslValidateCertificate": true
}
}]
}
}2. .cdsrc-private.json (cds bind)
Most secure option for cloud credentials. Uses CAP binding.
{
"requires": {
"db": {
"kind": "hana",
"binding": {
"type": "cf",
"apiEndpoint": "https://api.cf.eu10.hana.ondemand.com",
"org": "my-org",
"space": "dev",
"instance": "my-hana-hdi"
}
}
}
}3. .env File
Environment variables with VCAP_SERVICES.
VCAP_SERVICES={"hana":[{"credentials":{"host":"...","port":"443",...}}]}4. --conn Parameter
Specify custom connection file.
hana-cli tables --conn ./my-connection.json5. ${homedir}/.hana-cli/
User-level configuration directory.
6. default-env.json
Project-level default connection.
{
"VCAP_SERVICES": {
"hana": [{
"name": "hana-db",
"credentials": {
"host": "hostname",
"port": "30015",
"user": "SYSTEM",
"password": "Password123"
}
}]
}
}7. ${homedir}/.hana-cli/default.json (Lowest Priority)
Global fallback configuration.
---
Connection Methods
Interactive Connection
# Prompts for all parameters
hana-cli connect
# Partial parameters (prompts for missing)
hana-cli connect -n "myhost:443" -u MYUSERDirect Connection
# Full specification
hana-cli connect -n "hostname:443" -u USER -p PASSWORD --encrypt --save
# Using user store key
hana-cli connect -U MYKEYService Key Connection (HANA Cloud)
# Interactive service key setup
hana-cli connectViaServiceKey---
SSL/TLS Configuration
Enable Encryption
hana-cli connect --encrypt true
# or
hana-cli connect -e
# or
hana-cli connect --sslCustom Trust Store
# Specify certificate file
hana-cli connect --trustStore /path/to/DigiCertGlobalRootCA.crt
# Alternative aliases
hana-cli connect --Trust /path/to/cert.pem
hana-cli connect -t /path/to/cert.pemHANA Cloud SSL
For SAP HANA Cloud, SSL is required. The connection automatically uses:
- Port 443
- SSL encryption enabled
- DigiCert Global Root CA (usually pre-installed)
---
Credential Storage
Save Credentials
# Save after connection (default behavior)
hana-cli connect -n "host:port" -u USER -p PASS --save
# Don't save
hana-cli connect --save falseCredential Files Created
| File | Purpose |
|---|---|
default-env.json | Standard connection |
default-env-admin.json | Admin connection |
.cdsrc-private.json | CDS binding (gitignored) |
---
Security Best Practices
DO:
- Use
cds bindfor cloud credentials (no local storage) - Add
default-env*.jsonto.gitignore - Add
.cdsrc-private.jsonto.gitignore - Use service keys for HANA Cloud
- Enable SSL/TLS for all connections
- Use user store keys when available
DON'T:
- Commit credentials to version control
- Use plaintext passwords in scripts
- Disable SSL certificate validation in production
- Share admin credentials
---
Connection File Templates
HANA Cloud Connection
{
"VCAP_SERVICES": {
"hana": [{
"name": "hana-cloud",
"label": "hana",
"credentials": {
"host": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.hana.trial-eu10.hanacloud.ondemand.com",
"port": "443",
"user": "DBADMIN",
"password": "SecurePassword123!",
"schema": "DBADMIN",
"encrypt": true,
"sslValidateCertificate": true
}
}]
}
}On-Premise HANA Connection
{
"VCAP_SERVICES": {
"hana": [{
"name": "hana-onprem",
"label": "hana",
"credentials": {
"host": "hana.company.internal",
"port": "30015",
"user": "DEVELOPER",
"password": "Password123",
"schema": "MYSCHEMA"
}
}]
}
}HDI Container Connection
{
"VCAP_SERVICES": {
"hana": [{
"name": "hdi-container",
"label": "hana",
"credentials": {
"host": "hostname",
"port": "443",
"user": "CONTAINER_USER",
"password": "ContainerPass",
"schema": "CONTAINER_SCHEMA",
"hdi_user": "CONTAINER_USER",
"hdi_password": "ContainerPass"
}
}]
}
}---
Troubleshooting Connections
Check Status
hana-cli statusTest Connection
# Simple query test
hana-cli querySimple -q "SELECT CURRENT_USER FROM DUMMY"Common Issues
| Error | Cause | Solution |
|---|---|---|
| Connection refused | Wrong host/port | Verify hostname and port |
| SSL handshake failed | Certificate issue | Add --trustStore |
| Authentication failed | Wrong credentials | Check user/password |
| Insufficient privilege | Missing permissions | Check user roles |
Diagnose Privileges
hana-cli privilegeError
hana-cli inspectUser---
Connection Profiles
Use profiles for multiple environments:
# Use specific profile
hana-cli tables --profile dev
hana-cli tables --profile prod
# Profile stored in connection file---
Reference: [https://github.com/SAP-samples/hana-developer-cli-tool-example](https://github.com/SAP-samples/hana-developer-cli-tool-example*)
SAP HANA CLI - Database Inspection Functions
Source: https://github.com/SAP-samples/hana-developer-cli-tool-example/blob/main/utils/dbInspect.js
Detailed documentation of the database inspection functions used by hana-cli.
---
Version & Metadata Functions
getHANAVersion(db)
Returns HANA version information.
// Returns: { version: "2.00.045", versionMajor: 2 }System Table: M_DATABASE
isCalculationView(db, schema, viewId)
Checks if a view is a Calculation View.
System Table: _SYS_BI.BIMC_REPORTABLE_VIEWS
Note: HANA 2.0+ only
---
Table Inspection Functions
getTable(db, schema, tableId)
Returns table metadata.
Returns:
| Field | Description |
|---|---|
| TABLE_NAME | Table name |
| TABLE_OID | Object ID |
| TABLE_TYPE | Table type |
| HAS_PRIMARY_KEY | Primary key exists |
| UNLOAD_PRIORITY | Memory priority |
| IS_PRELOAD | Preload enabled |
System Table: TABLES
getTableFields(db, tableOid)
Returns column metadata for a table.
Returns:
| Field | Description |
|---|---|
| COLUMN_NAME | Column name |
| DATA_TYPE_NAME | Data type |
| LENGTH | Field length |
| SCALE | Decimal scale |
| IS_NULLABLE | Nullable flag |
| DEFAULT_VALUE | Default value |
| POSITION | Column position |
System Table: TABLE_COLUMNS
getConstraints(db, object)
Returns PRIMARY KEY constraints.
---
View Inspection Functions
getView(db, schema, viewId)
Returns view metadata.
Returns:
| Field | Description |
|---|---|
| VIEW_NAME | View name |
| VIEW_OID | Object ID |
| COMMENTS | Documentation |
| VIEW_TYPE | View type |
Note: Version-aware queries (HANA 1.0 vs 2.0+)
getViewFields(db, viewOid)
Returns view column metadata.
System Table: VIEW_COLUMNS
getViewParameters(db, viewOid)
Returns view input parameters.
System Table: VIEW_PARAMETERS
getCalcViewFields(db, schema, viewId, viewOid)
Returns Calculation View field metadata.
System Table: _SYS_BI.BIMC_DIMENSION_VIEW
Returns:
| Field | Description |
|---|---|
| POSITION | Field position |
| DATA_TYPE_NAME | Data type |
| SCALE | Decimal scale |
| KEY_COLUMN_NAME | Key indicator |
getCalcViewParameters(db, schema, viewId, viewOid)
Returns Calculation View parameters.
System Table: _SYS_BI.BIMC_VARIABLE_VIEW
Returns:
| Field | Description |
|---|---|
| PARAMETER_NAME | Parameter name |
| DATA_TYPE_NAME | Data type |
| MANDATORY | Required flag |
| DEFAULT_VALUE | Default value |
---
Procedure & Function Functions
getProcedure(db, schema, procedure)
Returns procedure metadata.
Returns:
| Field | Description |
|---|---|
| PROCEDURE_OID | Object ID |
| SQL_SECURITY | Security mode |
| INPUT_PARAMETER_COUNT | Input params |
| OUTPUT_PARAMETER_COUNT | Output params |
| READ_ONLY | Read-only flag |
| IS_VALID | Validity status |
System Table: PROCEDURES
getProcedurePrams(db, procOid)
Returns procedure parameters.
System Table: PROCEDURE_PARAMETERS
getProcedurePramCols(db, procOid)
Returns procedure parameter columns (for table-type params).
System Table: PROCEDURE_PARAMETER_COLUMNS
getFunction(db, schema, functionName)
Returns function metadata.
Returns:
| Field | Description |
|---|---|
| FUNCTION_OID | Object ID |
| SQL_SECURITY | Security mode |
| INPUT_PARAMETER_COUNT | Input params |
| RETURN_VALUE_COUNT | Return values |
System Table: FUNCTIONS
getFunctionPrams(db, funcOid)
Returns function parameters.
Returns:
| Field | Description |
|---|---|
| PARAMETER_NAME | Parameter name |
| DATA_TYPE_NAME | Data type |
| PARAMETER_TYPE | IN/OUT/INOUT |
System Table: FUNCTION_PARAMETERS
getFunctionPramCols(db, funcOid)
Returns function parameter columns.
---
Utility Functions
getDef(db, schema, Id)
Returns object creation statement.
System Procedure: GET_OBJECT_DEFINITION
getGeoColumns(db, object, field, type)
Returns SRS_ID for spatial geometry columns.
formatCDS(db, object, fields, constraints, type, schema, parent, parameters)
Formats database object as CDS entity.
Features:
- Type mapping (HANA to CDS)
- Name normalization
- Constraint handling
- Parameter support
parseSQLOptions(output, cdsSource)
Extracts extended SQL syntax via regex:
- PARTITION clauses
- UNLOAD PRIORITY
- AUTO MERGE settings
---
System Tables Summary
| Table | Purpose |
|---|---|
M_DATABASE | Version info |
TABLES | Table metadata |
TABLE_COLUMNS | Column definitions |
VIEWS | View metadata |
VIEW_COLUMNS | View columns |
VIEW_PARAMETERS | View input params |
PROCEDURES | Procedure metadata |
PROCEDURE_PARAMETERS | Procedure params |
PROCEDURE_PARAMETER_COLUMNS | Table-type columns |
FUNCTIONS | Function metadata |
FUNCTION_PARAMETERS | Function params |
_SYS_BI.BIMC_REPORTABLE_VIEWS | Calc view detection |
_SYS_BI.BIMC_DIMENSION_VIEW | Calc view fields |
_SYS_BI.BIMC_VARIABLE_VIEW | Calc view variables |
---
Reference: [https://github.com/SAP-samples/hana-developer-cli-tool-example/blob/main/utils/dbInspect.js](https://github.com/SAP-samples/hana-developer-cli-tool-example/blob/main/utils/dbInspect.js*)
SAP HANA CLI - Development Environment Reference
Source: https://github.com/SAP-samples/hana-developer-cli-tool-example
Configuration for development environments, testing, and multi-database support.
---
DevContainer Setup
The repository includes VS Code DevContainer configuration for consistent development environments.
Container Base
# Base image: Node.js 22 on Debian Buster
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-22-busterSystem Packages Installed
# Cloud Foundry CLI
apt-get install cf8-cli
# Utilities
apt-get install git jqGlobal npm Packages
npm install -g @ui5/cli
npm install -g @sap/cds-dk
npm install -g yo
npm install -g @sap/generator-hdb-project
npm install -g @sap/generator-fiori
npm install -g typescriptVS Code Extensions (21 total)
| Category | Extensions |
|---|---|
| SAP Tools | CDS Language Support, Fiori Tools, SAP UX Pack, HANA Driver, XML Toolkit |
| Development | ESLint, Beautify, IntelliCode, REST Client |
| Productivity | GitLens, Bracket Pair Colorizer, Path IntelliSense |
| Other | Yeoman UI, Version Lens, VS Code Icons |
Port Forwarding
"forwardPorts": [4004, 3010]- 4004: CAP default server port
- 3010: hana-cli UI default port
Post-Creation Setup
bash -i install-btp.shInstalls BTP CLI from SAP GitHub repository.
---
Multi-Database Support
The hana-cli supports multiple database backends through abstraction.
Database Adapters
| File | Database | Purpose |
|---|---|---|
hanaCDS.js | SAP HANA | CDS-based connection via CAP |
hanaDirect.js | SAP HANA | Direct connection via hdb |
postgres.js | PostgreSQL | PostgreSQL backend |
sqlite.js | SQLite | SQLite backend |
Backend Selection
Database backend is selected based on: 1. Connection configuration 2. CDS profile settings 3. Command-specific requirements
Database-Specific Commands
| Command | Purpose |
|---|---|
tablesPG | List tables (PostgreSQL) |
tablesSQLite | List tables (SQLite) |
tables | List tables (HANA default) |
---
XS API Support (On-Premise)
For on-premise XSA environments, additional utilities are available.
XS Configuration Functions
| Function | Purpose |
|---|---|
getCFConfig() | Read ~/.xsconfig |
getCFOrg() | Get target organization |
getCFSpace() | Get target space |
getCFTarget() | Get API endpoint |
XS Service Discovery
| Function | Purpose |
|---|---|
getServices() | List all services |
getServiceGUID(service) | Get service GUID |
getServicePlans(guid) | Get service plans |
getHANAInstances() | List HANA instances |
getHDIInstances() | List HDI instances |
---
SQL Injection Prevention
The tool includes built-in SQL injection protection.
Validation Functions
| Function | Purpose |
|---|---|
isAcceptableParameter(value, maxToken) | Validate SQL parameter |
isAcceptableQuotedParameter(value) | Validate quoted strings |
escapeDoubleQuotes(value) | Escape " characters |
escapeSingleQuotes(value) | Escape ' characters |
Security Features
- Comment detection (
--and/* */) - Quote nesting tracking
- Token counting
- Separator boundary enforcement
---
Testing Configuration
Test Framework
- Framework: Mocha
- Reporter: Mochawesome (HTML reports)
- Timeout: 10 seconds
- Parallel: Enabled
Configuration (.mocharc.json)
{
"timeout": "10s",
"parallel": true,
"reporter": "mochawesome",
"require": ["./tests/helper.js", "mochawesome/register"]
}Test Files
| Test | Purpose |
|---|---|
SystemInfo.Test.js | System info commands |
btpInfo.Test.js | BTP info commands |
btpSubs.Test.js | BTP subscriptions |
callProcedure.Test.js | Procedure execution |
status.Test.js | Connection status |
version.Test.js | Version info |
---
Fiori LaunchPad Configuration
Tile Groups
List Objects (9 tiles):
- Containers, Data Types, Functions, Indexes
- Schemas, Tables, Table Inspection
- Views, View Inspection
Admin (3 tiles):
- Features, Feature Usage, SQL Query
CF/XS (5 tiles):
- HDI, SBSS, Schema, SecureStore, UPS instances
Applications
| App | Path | Purpose |
|---|---|---|
| systemInfo | /systemInfo | System dashboard |
| readMe | /readMe | Documentation |
| changeLog | /changeLog | Version history |
| massConvert | /massConvert | Batch conversion |
---
Version Checking
Node.js Version Validation
// Reads engines.node from package.json
// Current requirement: ≥20.19.0Update Notifications
The CLI includes update notification via update-notifier package.
---
UI5 Configuration
ui5.yaml Settings
specVersion: "1.0"
type: application
metadata:
name: test1
server:
customMiddleware:
- name: fiori-tools-proxy
configuration:
backend:
- path: /sap/opu/odata
url: http://localhost
ui5:
path:
- /resources
- /test-resources
url: https://ui5.sap.comTheme Support
- Light:
sap_horizon - Dark:
sap_horizon_dark - Legacy:
sap_fiori_3_dark
---
Building from Source
Prerequisites
# Node.js 20.19.0 or higher
node --version
# Remove SAP registry if set
npm config delete @sap:registryInstallation
# Clone repository
git clone https://github.com/SAP-samples/hana-developer-cli-tool-example
# Install dependencies
cd hana-developer-cli-tool-example
npm install
# Link globally
npm linkUsing DevContainer
1. Open in VS Code with Remote-Containers extension 2. Select "Reopen in Container" 3. Wait for container build 4. Run npm install && npm link
---
Reference: [https://github.com/SAP-samples/hana-developer-cli-tool-example](https://github.com/SAP-samples/hana-developer-cli-tool-example*)
SAP HANA CLI - HDI Container Management
Source: https://github.com/SAP-samples/hana-developer-cli-tool-example
HDI (HANA Deployment Infrastructure) containers provide isolated runtime environments for database artifacts.
---
HDI Command Overview
| Command | Purpose |
|---|---|
activateHDI | Enable HDI service |
adminHDI | Assign HDI admin privileges |
adminHDIGroup | Manage group administrators |
containers | List containers |
createContainer | Create new container |
createContainerUsers | Create access users |
dropContainer | Remove container |
createGroup | Create container group |
dropGroup | Remove container group |
---
Activate HDI Service
Enable HDI for a database tenant.
# Activate HDI
hana-cli activateHDI
# For specific tenant
hana-cli activateHDI [tenant]Prerequisites: SYSTEM user or equivalent privileges.
---
HDI Administration
Assign HDI Admin
# Make user an HDI administrator
hana-cli adminHDI [user]Group Administration
# Add group administrator
hana-cli adminHDIGroup [group] [user]---
Container Operations
List Containers
# List all containers
hana-cli containers
# With aliases
hana-cli cont
hana-cli listContainers
# Filter by container name pattern
hana-cli containers -c "MY_APP*"
# Filter by group
hana-cli containers -g "DEV_GROUP"
# Limit results
hana-cli containers -l 50Options:
| Option | Alias | Default | Description |
|---|---|---|---|
| container | c | * | Container filter pattern |
| containerGroup | g | * | Group filter pattern |
| limit | l | 200 | Maximum results |
Output: Container name, group, schema, creator, creation timestamp (UTC).
UI Alternative:
hana-cli containersUICreate Container
# Create new container
hana-cli createContainer [container] [group]
# Example
hana-cli createContainer MY_APP_HDI DEV_GROUPCreate Container Users
Creates the standard HDI access users for a container.
# Create users for container
hana-cli createContainerUsers [container]
# Example
hana-cli createContainerUsers MY_APP_HDIUsers Created:
- Runtime user (read/execute)
- Design-time user (deploy artifacts)
- Admin user (full access)
Drop Container
# Remove container
hana-cli dropContainer [container]
# Example
hana-cli dropContainer MY_APP_HDIWarning: This permanently deletes all artifacts in the container.
---
Container Groups
Create Group
# Create container group
hana-cli createGroup [group]
# Example
hana-cli createGroup DEV_GROUPDrop Group
# Remove container group
hana-cli dropGroup [group]
# Example
hana-cli dropGroup DEV_GROUPNote: Group must be empty before deletion.
---
HANA Cloud HDI Instances
For SAP HANA Cloud, use cloud-specific commands:
# List Cloud HDI instances
hana-cli hanaCloudHDIInstances
# UI version
hana-cli hanaCloudHDIInstancesUI---
HDI Container Workflow
Typical Development Workflow
1. Enable HDI (if not enabled):
hana-cli activateHDI2. Create group (optional organization):
hana-cli createGroup MY_PROJECT_GROUP3. Create container:
hana-cli createContainer MY_APP_HDI MY_PROJECT_GROUP4. Create users:
hana-cli createContainerUsers MY_APP_HDI5. Verify:
hana-cli containers -c "MY_APP*"Cleanup Workflow
1. List containers:
hana-cli containers2. Drop container:
hana-cli dropContainer MY_APP_HDI3. Drop group (if empty):
hana-cli dropGroup MY_PROJECT_GROUP---
HDI Connection in default-env.json
{
"VCAP_SERVICES": {
"hana": [{
"name": "hdi-container",
"label": "hana",
"credentials": {
"host": "hostname",
"port": "443",
"user": "MY_APP_HDI_RT",
"password": "RuntimeUserPassword",
"schema": "MY_APP_HDI",
"hdi_user": "MY_APP_HDI_DT",
"hdi_password": "DesignTimePassword",
"certificate": "-----BEGIN CERTIFICATE-----..."
}
}]
}
}---
Common Issues
| Issue | Cause | Solution |
|---|---|---|
| HDI not activated | Service disabled | Run activateHDI |
| Cannot create container | Insufficient privileges | Get HDI admin rights |
| Container exists | Name conflict | Use unique name |
| Cannot drop group | Group not empty | Drop containers first |
---
Reference: [https://github.com/SAP-samples/hana-developer-cli-tool-example](https://github.com/SAP-samples/hana-developer-cli-tool-example*)
SAP HANA CLI - Mass Operations Reference
Source: https://github.com/SAP-samples/hana-developer-cli-tool-example/blob/main/utils/massConvert.js
Commands and functions for batch operations on database objects.
---
Mass Convert Command
massConvert
Batch convert database objects to various formats.
Aliases: mc, massconvert, massConv, massconv
hana-cli massConvert [schema] [table] [view]UI Alternative: massConvertUI
---
Conversion Types
HDBTABLE Format
Generates .hdbtable files packaged in ZIP format.
hana-cli massConvert -s MYSCHEMA -o hdbtableFunctions:
hdbtableTablesSQL()- SQL-based table conversionhdbtableTables()- CDS-compiled table conversionhdbtableViewsSQL()- SQL-based view conversionhdbtableViews()- CDS-compiled view conversion
HDBMIGRATIONTABLE Format
Generates .hdbmigrationtable files with version headers.
hana-cli massConvert -s MYSCHEMA -o hdbmigrationtableFunctions:
hdbmigrationtableTablesSQL()- SQL-based migration formathdbmigrationtableTables()- CDS-compiled migration format
CDS Format
Generates unified .cds source file.
hana-cli massConvert -s MYSCHEMA -o cdsFunctions:
cdsTables()- Extracts table definitionscdsViews()- Extracts view definitions with parameters
---
Configuration Options
| Option | Type | Description |
|---|---|---|
useHanaTypes | boolean | Apply HANA-specific data types |
keepPath | boolean | Preserve namespace paths |
noColons | boolean | Remove colon syntax |
useExists | boolean | Use EXISTS conditions |
useQuoted | boolean | Quote identifiers |
useCatalogPure | boolean | SQL-based catalog extraction |
namespace | string | CDS namespace prefix |
limit | number | Restrict result set size |
log | boolean | Generate JSON audit logs |
table | string | Pattern filter for tables |
view | string | Pattern filter for views |
---
Output Functions
writeZip()
Compresses files using DEFLATE compression.
writeCDS()
Writes unified CDS file containing all entities.
writeSynonyms()
Stores synonym mappings for reference.
writeLog()
Creates JSON execution logs for auditing.
---
Mass Rename Command
massRename
Batch rename database objects.
hana-cli massRename [schema]Use Cases:
- Standardize naming conventions
- Apply prefixes/suffixes
- Case conversion
---
Mass Users Command
massUsers
Bulk user operations.
hana-cli massUsersUse Cases:
- Create multiple users
- Assign roles in bulk
- User cleanup operations
---
Workflow Example
Convert Entire Schema to CDS
# Interactive mode
hana-cli massConvert
# Direct specification
hana-cli massConvert -s MYSCHEMA
# With options
hana-cli massConvert -s MYSCHEMA --useHanaTypes --namespace "my.app"
# Generate log file
hana-cli massConvert -s MYSCHEMA --logUsing the UI
# Launch browser-based interface
hana-cli massConvertUIThe UI provides:
- Schema browser
- Object selection
- Preview before conversion
- Download options
---
Output Structure
ZIP Archive Contents
output.zip
├── src/
│ ├── CUSTOMERS.hdbtable
│ ├── ORDERS.hdbtable
│ ├── PRODUCTS.hdbtable
│ └── ...
└── synonyms.json (if applicable)CDS File Structure
namespace my.schema;
entity CUSTOMERS {
key ID : Integer;
NAME : String(100);
EMAIL : String(255);
}
entity ORDERS {
key ID : Integer;
CUSTOMER_ID : Integer;
ORDER_DATE : Date;
}---
Best Practices
1. Test with limit first: Use --limit 10 to verify output format 2. Review generated files: Check for naming conflicts 3. Backup before conversion: Preserve original definitions 4. Use namespaces: Apply consistent CDS namespaces 5. Enable logging: Track what was converted
---
Reference: [https://github.com/SAP-samples/hana-developer-cli-tool-example/blob/main/utils/massConvert.js](https://github.com/SAP-samples/hana-developer-cli-tool-example/blob/main/utils/massConvert.js*)
SAP HANA CLI - Output Formats Reference
Source: https://github.com/SAP-samples/hana-developer-cli-tool-example
The hana-cli supports 17+ output formats for database metadata conversion and export.
---
Format Overview
| Format | Extension | Use Case |
|---|---|---|
tbl | - | Console table display (default) |
json | .json | JSON data exchange |
yaml | .yaml | YAML configuration |
csv | .csv | Spreadsheet import |
excel | .xlsx | Excel file export |
cds | .cds | CAP CDS definitions |
cdl | .cds | CDS Language format |
hdbcds | .hdbcds | HANA native CDS |
hdbtable | .hdbtable | HDB table definitions |
hdbmigrationtable | .hdbmigrationtable | Migration tables |
sql | .sql | SQL DDL statements |
sqlite | .sql | SQLite-compatible SQL |
postgres | .sql | PostgreSQL-compatible SQL |
edmx | .edmx | OData EDMX metadata |
edm | - | OData EDM |
annos | .xml | OData annotations |
graphql | .graphql | GraphQL schema |
openapi | .json | OpenAPI specification |
swgr | .json | Swagger specification |
jsdoc | - | JSDoc documentation |
---
Using Output Formats
Syntax
hana-cli <command> --output <format>
# or
hana-cli <command> -o <format>Examples
# Console table (default)
hana-cli inspectTable -s SCHEMA -t TABLE
# JSON output
hana-cli inspectTable -s SCHEMA -t TABLE -o json
# CDS format
hana-cli inspectTable -s SCHEMA -t TABLE -o cds
# OpenAPI spec
hana-cli inspectTable -s SCHEMA -t TABLE -o openapi---
Format Details
Console Formats
tbl (Table)
Human-readable table format for console display.
hana-cli tables -o tblOutput:
┌─────────────────┬────────────┬──────────┐
│ TABLE_NAME │ SCHEMA │ ROWS │
├─────────────────┼────────────┼──────────┤
│ CUSTOMERS │ MYSCHEMA │ 1000 │
│ ORDERS │ MYSCHEMA │ 5000 │
└─────────────────┴────────────┴──────────┘---
Data Exchange Formats
json
Standard JSON format.
hana-cli inspectTable -t CUSTOMERS -o jsonOutput:
{
"table": "CUSTOMERS",
"schema": "MYSCHEMA",
"columns": [
{"name": "ID", "type": "INTEGER", "nullable": false},
{"name": "NAME", "type": "NVARCHAR", "length": 100}
]
}yaml
YAML format for configuration files.
hana-cli inspectTable -t CUSTOMERS -o yamlcsv
Comma-separated values for spreadsheet import.
hana-cli querySimple -q "SELECT * FROM CUSTOMERS" -o csvexcel
Microsoft Excel format (.xlsx).
hana-cli querySimple -q "SELECT * FROM CUSTOMERS" -o excel -f ./output -n customers---
CAP CDS Formats
cds
SAP Cloud Application Programming Model CDS.
hana-cli inspectTable -t CUSTOMERS -o cdsOutput:
entity Customers {
key ID : Integer;
NAME : String(100);
EMAIL : String(255);
CREATED_AT : Timestamp;
}cdl
CDS Language format (similar to cds).
hana-cli inspectTable -t CUSTOMERS -o cdl---
HANA Native Formats
hdbcds
HANA native CDS format.
hana-cli inspectTable -t CUSTOMERS -o hdbcdsOutput:
context myschema {
entity CUSTOMERS {
key ID : Integer;
NAME : String(100);
};
};hdbtable
HDB table definition format.
hana-cli inspectTable -t CUSTOMERS -o hdbtableOutput:
COLUMN TABLE "MYSCHEMA"."CUSTOMERS" (
"ID" INTEGER NOT NULL,
"NAME" NVARCHAR(100),
PRIMARY KEY ("ID")
)hdbmigrationtable
Migration table format for HDI.
hana-cli inspectTable -t CUSTOMERS -o hdbmigrationtable---
SQL Formats
sql
Standard SQL DDL.
hana-cli inspectTable -t CUSTOMERS -o sqlOutput:
CREATE TABLE "MYSCHEMA"."CUSTOMERS" (
"ID" INTEGER NOT NULL,
"NAME" NVARCHAR(100),
PRIMARY KEY ("ID")
);sqlite
SQLite-compatible SQL.
hana-cli inspectTable -t CUSTOMERS -o sqlitepostgres
PostgreSQL-compatible SQL.
hana-cli inspectTable -t CUSTOMERS -o postgres---
OData Formats
edmx
OData Entity Data Model XML.
hana-cli inspectTable -t CUSTOMERS -o edmxOutput:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="4.0">
<edmx:DataServices>
<Schema Namespace="myschema">
<EntityType Name="Customers">
<Key>
<PropertyRef Name="ID"/>
</Key>
<Property Name="ID" Type="Edm.Int32" Nullable="false"/>
<Property Name="NAME" Type="Edm.String" MaxLength="100"/>
</EntityType>
</Schema>
</edmx:DataServices>
</edmx:Edmx>edm
OData EDM format.
annos
OData annotations XML.
hana-cli inspectTable -t CUSTOMERS -o annos---
API Formats
openapi / swgr
OpenAPI/Swagger specification.
hana-cli inspectTable -t CUSTOMERS -o openapiOutput:
{
"openapi": "3.0.0",
"info": {"title": "CUSTOMERS API"},
"paths": {
"/Customers": {
"get": {...},
"post": {...}
}
}
}graphql
GraphQL schema definition.
hana-cli inspectTable -t CUSTOMERS -o graphqlOutput:
type Customers {
ID: Int!
NAME: String
EMAIL: String
}
type Query {
Customers: [Customers]
}---
Documentation Formats
jsdoc
JSDoc-style documentation.
hana-cli inspectProcedure -p MY_PROC -o jsdoc---
Mass Conversion
Convert multiple objects at once:
# Convert all tables in schema to CDS
hana-cli massConvert -s MYSCHEMA
# UI version for interactive selection
hana-cli massConvertUI---
Output Options
HANA Types
Use native HANA data types instead of generic types:
hana-cli inspectTable -t CUSTOMERS -o cds --useHanaTypes
# or
hana-cli inspectTable -t CUSTOMERS -o cds --hanaQuoted Identifiers
Preserve case-sensitive identifiers:
hana-cli inspectTable -t CUSTOMERS -o sql --useQuoted
# or
hana-cli inspectTable -t CUSTOMERS -o sql -qFile Output
Save to file instead of console:
hana-cli querySimple -q "SELECT * FROM T" -o json -f ./output -n data
# Creates: ./output/data.json---
Format Compatibility Matrix
| Source | CDS | SQL | EDMX | GraphQL | OpenAPI |
|---|---|---|---|---|---|
| Tables | Yes | Yes | Yes | Yes | Yes |
| Views | Yes | Yes | Yes | Yes | Yes |
| Procedures | Partial | Yes | No | No | No |
| Functions | Partial | Yes | No | No | No |
| Calc Views | Yes | Yes | Yes | Yes | Yes |
---
Reference: [https://github.com/SAP-samples/hana-developer-cli-tool-example](https://github.com/SAP-samples/hana-developer-cli-tool-example*)
SAP HANA CLI - System Administration Reference
Source: https://github.com/SAP-samples/hana-developer-cli-tool-example
Commands for system monitoring, configuration, and administration.
---
System Information Commands
systemInfo
Display comprehensive system details.
Aliases: si, sysinfo
hana-cli systemInfoUI Alternative: systemInfoUI
Queries:
SELECT * FROM M_SYSTEM_OVERVIEWSELECT * FROM M_SERVICES
Output Modes:
| Mode | Description |
|---|---|
| Basic | DB user, HANA version, overview, services |
| Environment | Connection options, HDI credentials |
| DBX | DB type, credentials for Database Explorer |
hostInformation
Display host details.
hana-cli hostInformationversion
Display hana-cli version.
hana-cli version---
Database Features
features
List SAP HANA database features.
Aliases: fe, Features
hana-cli featuresQuery: SELECT * FROM M_FEATURES
UI Alternative: featuresUI
featureUsage
Display feature usage metrics.
hana-cli featureUsageUI Alternative: featureUsageUI
---
Storage & Resources
dataVolumes
Display data volume information.
hana-cli dataVolumesdisks
Display disk information.
hana-cli disksports
List database port assignments.
hana-cli portsreclaim
Reclaim database resources.
Aliases: re
hana-cli reclaimOperations Executed: 1. ALTER SYSTEM RECLAIM LOB SPACE - Recover LOB storage 2. ALTER SYSTEM RECLAIM LOG - Free transaction log space 3. ALTER SYSTEM RECLAIM DATAVOLUME 105 DEFRAGMENT - Defragment storage
---
Configuration Files
iniFiles
List INI configuration files.
Aliases: if, ini
hana-cli iniFilesQuery: SELECT * FROM M_INIFILES
iniContents
Display INI file contents.
hana-cli iniContents [file]Query: SELECT * FROM M_INIFILE_CONTENTS
---
Tracing & Debugging
traces
List trace files.
Aliases: tf, Traces
hana-cli tracesQuery: SELECT * FROM M_TRACEFILES
traceContents
Display trace file contents.
hana-cli traceContents [trace]---
Data Types
dataTypes
Display HANA data type specifications.
hana-cli dataTypesQuery: SELECT TYPE_NAME, COLUMN_SIZE, CREATE_PARAMS FROM DATA_TYPES
UI Alternative: dataTypesUI
---
System Tables Reference
| Table | Purpose | Command |
|---|---|---|
M_SYSTEM_OVERVIEW | System overview | systemInfo |
M_SERVICES | Running services | systemInfo |
M_FEATURES | Available features | features |
M_TRACEFILES | Trace file list | traces |
M_INIFILES | INI file list | iniFiles |
M_INIFILE_CONTENTS | INI content | iniContents |
DATA_TYPES | Type definitions | dataTypes |
---
Common Workflows
Health Check
# System overview
hana-cli systemInfo
# Check features
hana-cli features
# Review configuration
hana-cli iniFilesPerformance Investigation
# View trace files
hana-cli traces
# Check specific trace
hana-cli traceContents [tracefile]
# Review feature usage
hana-cli featureUsageStorage Management
# Check volumes
hana-cli dataVolumes
# Check disks
hana-cli disks
# Reclaim space
hana-cli reclaim---
Output Examples
systemInfo Output
Database User: DBADMIN
HANA Version: 2.00.059.00
System Overview:
┌────────────────────┬─────────────────────────┐
│ NAME │ VALUE │
├────────────────────┼─────────────────────────┤
│ Database Name │ HXE │
│ Database Version │ 2.00.059.00 │
│ Start Time │ 2025-11-22 08:00:00 │
└────────────────────┴─────────────────────────┘features Output
┌───────────────────────────┬─────────┐
│ FEATURE_NAME │ ENABLED │
├───────────────────────────┼─────────┤
│ Calculation Views │ TRUE │
│ Graph Engine │ TRUE │
│ Document Store │ TRUE │
│ Script Server │ TRUE │
└───────────────────────────┴─────────┘---
Reference: [https://github.com/SAP-samples/hana-developer-cli-tool-example](https://github.com/SAP-samples/hana-developer-cli-tool-example*)
SAP HANA CLI - Troubleshooting Guide
Source: https://github.com/SAP-samples/hana-developer-cli-tool-example
Common issues, diagnostic commands, and solutions.
---
Diagnostic Commands
Connection Status
hana-cli statusVerify current connection is active.
Privilege Error Analysis
hana-cli privilegeError [guid]Aliases: pe, getInsufficientPrivilegeErrorDetails
Diagnoses specific privilege errors using the error GUID.
System Procedure: SYS.GET_INSUFFICIENT_PRIVILEGE_ERROR_DETAILS
User Inspection
hana-cli inspectUser [user]View user metadata and privileges.
---
Common Issues
Connection Problems
| Error | Cause | Solution |
|---|---|---|
| Connection refused | Wrong host/port | Verify hostname and port |
| SSL handshake failed | Certificate issue | Add --trustStore |
| Authentication failed | Wrong credentials | Check user/password |
| Connection timeout | Network issue | Check firewall rules |
| Host not found | DNS issue | Use IP address |
Diagnostic Steps:
# 1. Check current status
hana-cli status
# 2. Test with explicit credentials
hana-cli connect -n "host:443" -u USER -p PASS --encrypt
# 3. Add trust store if needed
hana-cli connect --trustStore /path/to/cert.pemPermission Errors
| Error | Cause | Solution |
|---|---|---|
| Insufficient privilege | Missing role | Grant required roles |
| Object not found | Wrong schema | Check schema name |
| Access denied | Object ownership | Check privileges |
Diagnostic Steps:
# 1. Get error GUID from error message
# 2. Analyze with privilegeError
hana-cli privilegeError <guid>
# 3. Check user details
hana-cli inspectUser
# 4. Review available roles
hana-cli rolesHDI Container Issues
| Error | Cause | Solution |
|---|---|---|
| HDI not activated | Service disabled | Run activateHDI |
| Cannot create container | No admin rights | Get HDI admin role |
| Container exists | Name conflict | Use unique name |
| Cannot drop group | Not empty | Drop containers first |
Diagnostic Steps:
# 1. Check HDI status
hana-cli containers
# 2. Verify admin rights
hana-cli adminHDI
# 3. List container users
hana-cli createContainerUsers -c CONTAINER --listCloud Connection Issues
| Error | Cause | Solution |
|---|---|---|
| Instance not found | Wrong name | Verify instance name |
| Instance stopped | Not running | Run hanaCloudStart |
| Service key invalid | Expired/revoked | Regenerate key |
| BTP target wrong | Wrong subaccount | Reconfigure with btp |
Diagnostic Steps:
# 1. Check BTP target
hana-cli btpInfo
# 2. List instances
hana-cli hanaCloudInstances
# 3. Start if stopped
hana-cli hanaCloudStart <instance>
# 4. Reconfigure BTP
hana-cli btp---
Error Messages Reference
Connection Errors
"ECONNREFUSED"
Error: connect ECONNREFUSED 127.0.0.1:30015Solution: Check host and port, ensure database is running.
"SSL_ERROR_SYSCALL"
Error: SSL_ERROR_SYSCALLSolution: Enable encryption with --encrypt or add trust store.
"EHOSTUNREACH"
Error: connect EHOSTUNREACHSolution: Check network connectivity, VPN if required.
Authentication Errors
"Invalid username or password"
Error: authentication failedSolution: Verify credentials, check user is not locked.
"User is locked"
Error: user account is lockedSolution: Unlock user via HANA Studio or SQL.
Privilege Errors
"Insufficient privilege"
Error: insufficient privilege: Not authorizedSolution: Use privilegeError with GUID to diagnose, grant required roles.
---
Credential File Issues
Missing Credentials
# Check file discovery order
ls -la default-env*.json
ls -la .cdsrc-private.json
ls -la .envInvalid JSON
# Validate JSON syntax
cat default-env.json | python -m json.toolWrong Credentials Priority
Remember the priority order: 1. default-env-admin.json (with --admin) 2. .cdsrc-private.json (cds bind) 3. .env file 4. --conn parameter 5. default-env.json 6. ~/.hana-cli/default.json
---
System Resource Issues
Reclaim Resources
# Reclaim storage space
hana-cli reclaimExecutes:
ALTER SYSTEM RECLAIM LOB SPACEALTER SYSTEM RECLAIM LOGALTER SYSTEM RECLAIM DATAVOLUME 105 DEFRAGMENT
Check Storage
# View data volumes
hana-cli dataVolumes
# View disk info
hana-cli disks---
Debug Mode
Enable debug output:
# Set DEBUG environment variable
DEBUG=* hana-cli <command>
# Or use --debug flag if available
hana-cli <command> --debug---
Reporting Issues
# Open issue on GitHub
hana-cli issueOpens browser to create GitHub issue with:
- Version information
- Environment details
- Steps to reproduce
---
Getting Help
In-CLI Help
hana-cli --help
hana-cli <command> --helpDocumentation
hana-cli readMe
hana-cli openReadMe # Opens in browserChangelog
hana-cli changeLog
hana-cli openChangeLog # Opens in browser---
Reference: [https://github.com/SAP-samples/hana-developer-cli-tool-example](https://github.com/SAP-samples/hana-developer-cli-tool-example*)
SAP HANA CLI - Web UI Reference
Source: https://github.com/SAP-samples/hana-developer-cli-tool-example
The hana-cli includes a browser-based Fiori LaunchPad interface for visual operations.
---
Launching the Web UI
Main UI Command
hana-cli UIOpens a browser-based LaunchPad with all available applications.
Command-Specific UIs
Many commands have UI alternatives:
| Command | UI Command | Purpose |
|---|---|---|
tables | tablesUI | Browse tables visually |
containers | containersUI | Manage HDI containers |
massConvert | massConvertUI | Visual mass conversion |
querySimple | querySimpleUI | Query builder interface |
systemInfo | systemInfoUI | System dashboard |
schemas | schemasUI | Schema browser |
functions | functionsUI | Function browser |
indexes | indexesUI | Index browser |
dataTypes | dataTypesUI | Type reference |
features | featuresUI | Feature dashboard |
featureUsage | featureUsageUI | Usage metrics |
inspectTable | inspectTableUI | Table inspector |
changeLog | changeLogUI | Version history |
readMe | readMeUI | Documentation |
hanaCloudInstances | hanaCloudHDIInstancesUI | Cloud instances |
---
Architecture
Technology Stack
- Framework: SAPUI5 1.142.0
- Shell: SAP Universal Shell (ushell)
- Libraries:
sap.m- Mobile controlssap.ushell- Shell containersap.ui.layout- Layout componentssap.ui.rta- Runtime adaptationsap.uxap- Object page components
Theme Support
Automatic theme detection:
- Light mode:
sap_horizon - Dark mode:
sap_horizon_dark
// Theme detection
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
sap.ui.getCore().applyTheme('sap_horizon_dark');
}---
API Endpoints
GET /
Retrieves current prompts configuration.
// Returns JSON with current settings
{ schema: "MYSCHEMA", limit: 200, ... }PUT /
Updates prompts configuration.
// Request body
{ schema: "NEWSCHEMA", table: "MYTABLE" }---
Web Server Configuration
Default Port
Commands launch on port 3010 by default.
hana-cli cds -p 3010
hana-cli UI -p 4000 # Custom portPort Configuration
# Specify custom port
hana-cli <command>UI -p <port>Port range: 1-65535
---
Route Structure
| Route | Handler | Purpose |
|---|---|---|
/ | index.js | Main prompts API |
/dfa | dfa.js | Digital Assistant routes |
/docs | docs.js | Documentation routes |
/excel | excel.js | Excel export |
/inspect | hanaInspect.js | Object inspection |
/list | hanaList.js | Object listings |
/static | static.js | Static file serving |
/ws | webSocket.js | WebSocket connections |
---
Application Structure
app/
├── README.md
├── ui5.yaml
├── ui5-local.yaml
├── appconfig/
│ └── fioriSandboxConfig.json
├── dfa/
│ ├── library.js
│ ├── library-preload.js
│ └── help/
├── resources/
│ ├── index.html
│ ├── init.js
│ ├── favicon.ico
│ ├── WebAssistant.js
│ ├── common/
│ ├── inspect/
│ ├── massConvert/
│ ├── systemInfo/
│ └── tables/---
Features
Interactive Prompts
The UI provides visual input for all command parameters:
- Schema selection dropdowns
- Table/view pickers
- Output format selectors
- Limit/offset controls
Real-Time Results
Results display in formatted tables with:
- Sorting
- Filtering
- Pagination
- Export options
Swagger/OpenAPI Documentation
OData and REST endpoints include Swagger UI:
# Access API documentation
http://localhost:3010/api-docsGraphQL Endpoint
GraphQL support available at:
http://localhost:3010/graphql---
Integration with External Tools
Open Database Explorer
hana-cli openDBExplorerOpens HANA Database Explorer with current credentials.
Cloud Region Routing:
- us10, us20: US cloud cockpit URLs
- eu10, eu20: EU cloud cockpit URLs
- ap10, ap11, ap21: APAC cloud cockpit URLs
On-Premise: Queries M_INIFILE_CONTENTS for api_url.
Open Business Application Studio
hana-cli openBASOpens BAS with current BTP target.
---
Customization
Namespace Configuration
Custom UI5 namespace:
"sap.hanacli.common": "./common"Flexibility Services
Runtime UI adaptation via SessionStorageConnector.
---
Security
- Credentials passed via memory (not URL)
- Same-origin requests only
- Session-based authentication
---
Reference: [https://github.com/SAP-samples/hana-developer-cli-tool-example/tree/main/app](https://github.com/SAP-samples/hana-developer-cli-tool-example/tree/main/app*)
{
"requires": {
"db": {
"kind": "hana",
"binding": {
"type": "cf",
"apiEndpoint": "https://api.cf.<region>.hana.ondemand.com",
"org": "<org-name>",
"space": "<space-name>",
"instance": "<hdi-service-instance-name>",
"key": "<service-key-name>"
}
}
}
}
{
"VCAP_SERVICES": {
"hana": [
{
"name": "hana-db",
"label": "hana",
"tags": ["hana", "database", "relational"],
"credentials": {
"host": "<hostname>",
"port": "<port>",
"user": "<username>",
"password": "<password>",
"schema": "<schema>",
"encrypt": true,
"sslValidateCertificate": true,
"sslTrustStore": "<path-to-certificate>"
}
}
]
}
}