Skip to content
Learni
View all tutorials
Data & Analytics

How to Optimize SAP BW with HANA in 2026

22 minEXPERT
Lire en français

Introduction

SAP BW remains a cornerstone of enterprise data warehousing in 2026. With SAP HANA, performance skyrockets but requires precise modeling. This tutorial guides you step-by-step to optimize a complete BW model, from the persistence layer to virtual cubes. You'll learn to leverage calculation views and transformation scripts to reduce loading times by 70%. Each step includes ready-to-use functional code.

Prerequisites

  • Access to a SAP BW/4HANA 2023+ system
  • Advanced knowledge in BW modeling and SQL
  • HANA Studio and Eclipse installed
  • Developer rights on the source system

Creating the Staging Table

create_staging_table.sql
CREATE COLUMN TABLE "STAGING"."ZSTG_SALES" (
  "MANDT" NVARCHAR(3) NOT NULL,
  "VBELN" NVARCHAR(10) NOT NULL,
  "POSNR" NVARCHAR(6) NOT NULL,
  "MATNR" NVARCHAR(40),
  "NETWR" DECIMAL(15,2),
  PRIMARY KEY ("MANDT", "VBELN", "POSNR")
);

This staging table persists extracted data before transformation. Use COLUMN TABLE to benefit from HANA compression and read performance.

ABAP-like Transformation Script in SQL

transformation.sql
INSERT INTO "BW"."ZADS_SALES" 
SELECT 
  MANDT, VBELN, POSNR, MATNR, 
  NETWR * 1.2 AS NETWR_EUR
FROM "STAGING"."ZSTG_SALES"
WHERE NETWR > 0;

This script performs a simple transformation with currency calculation. Avoid cursors to stay in set-based mode and maximize HANA performance.

DataSource Configuration in JSON

datasource.json
{
  "name": "ZDS_SALES",
  "type": "Extractor",
  "source": "ECC",
  "delta": true,
  "fields": ["VBELN", "POSNR", "MATNR", "NETWR"]
}

The JSON file defines the DataSource with delta activation. Import it via the transport tool to ensure consistency across environments.

Automated Python Loading Script

load_data.py
import pyhdb
conn = pyhdb.connect(host='hana-server', port=30015, user='BWADMIN', password='xxx')
cursor = conn.cursor()
cursor.execute('CALL "BW"."ZPROC_LOAD_SALES"()')
conn.commit()

This Python script triggers the stored loading procedure. Use pyhdb for direct HANA connections and handle errors with try/except blocks.

Advanced Calculation View

calc_view.sql
CREATE CALCULATION VIEW "CV_SALES" AS
SELECT 
  MATNR,
  SUM(NETWR) AS TOTAL
FROM "BW"."ZADS_SALES"
GROUP BY MATNR;

The calculation view replaces classic cubes. Enable the cache flag for frequent queries and test with Explain Plan.

Process Chain Configuration File

process_chain.yaml
chain:
  name: ZPC_SALES
  steps:
    - type: DTP
      target: ZADS_SALES
    - type: Activation
      target: ZCUBE_SALES

This YAML file describes the process chain. Deploy it with the BW API to automate nightly loads.

Best Practices

  • Prefer calculation views over physical InfoCubes to reduce memory footprint
  • Enable partitioning on date fields in all fact tables
  • Use stored procedures instead of classic ABAP transformations
  • Monitor views with SAP HANA Studio and limit joins to 3 tables maximum
  • Document each BW object with standard metadata

Common Errors to Avoid

  • Forgetting to activate delta on DataSources leads to costly full reloads
  • Using SELECT * in transformations degrades HANA performance
  • Ignoring indexes on dimension tables causes query timeouts
  • Failing to test process chains in a quality environment before production

Further Reading

Deepen your skills with our advanced SAP BW training. Also explore modules on BW/4HANA and integrations with SAP Analytics Cloud.

How to Optimize SAP BW with HANA in 2026 | Learni