18 KiB
Graphical and SQL Views Reference
Source: https://github.com/SAP-docs/sap-datasphere/tree/main/docs/Acquiring-Preparing-Modeling-Data
Table of Contents
- Graphical Views
- SQL Views
- Entity-Relationship Models
- Intelligent Lookups
- View Operations
- Input Parameters
- Data Access Controls
- Persistence
- Validation and Performance
- SQL Reference
Graphical Views
Create views visually using drag-and-drop operations.
Prerequisites
Required Scoped Role Privileges:
| Privilege | Access | Description |
|---|---|---|
| Data Warehouse General | -R------ |
System access |
| Data Warehouse Data Builder | CRUD---- |
Create/edit/delete views |
| Space Files | CRUD---- |
Manage space objects |
The DW Modeler role template includes these privileges.
Creating a Graphical View
- Data Builder > New Graphical View
- Add source from repository or connection
- Add transformation nodes
- Configure output columns
- Save and deploy
Output Node Properties
Required Properties:
- Business Name (display name)
- Technical Name (immutable after saving)
- Package assignment (immutable after selection)
Semantic Usage Options:
| Type | Purpose | Use Case |
|---|---|---|
| Fact | Transactional data with measures | Sales, orders |
| Dimension | Master data for categorization | Products, customers |
| Hierarchy | Hierarchical structure | Org chart, geography |
| Text | Language-dependent labels | Translations |
| Relational Dataset | Generic relational data | Any data |
| Analytical Dataset | Analytics-ready (deprecated) | Legacy models |
| Hierarchy with Directory | Multiple parent-child hierarchies | Complex org structures |
Dimension Type: Standard or Fiscal Time (requires fiscal calendar configuration)
Exposure for Consumption:
- Enable OData, ODBC, JDBC access
- Required for external BI tools
- Note: DW Viewer role users can only preview if this is enabled
Analytical Mode Option:
- Optimized for analytical queries
- Automatic aggregation behavior
- Sends
USE_OLAP_PLANhint to SAP HANA
Data Preview Restrictions (DW Viewer Role):
- Cannot preview data if Expose for Consumption is disabled
- Can only preview data in the output node (not intermediate nodes)
Editor Toolbar Tools
| Tool | Purpose |
|---|---|
| Save/Save As | Design-time repository persistence |
| Deploy | Runtime environment activation |
| Share | Cross-space distribution |
| Preview Data | Node output visualization |
| Undo/Redo | Change reversal/restoration |
| Export | CSN/JSON file export |
| Impact & Lineage | Dependency graph visualization |
| Generate OData Request | OData API access preparation |
| Runtime Metrics | Performance analysis with Explain Plan generation |
| Generate Semantics | AI-assisted semantic type identification |
| Versions | Version history access |
| Details | Properties panel toggle |
Key Constraint
Operator Limitation: You can only create ONE of each operator type (Filter, Projection, Calculated Columns, Aggregation) per source or join.
Adding Sources
Source Types:
- Local tables
- Remote tables
- Views
- Shared entities
Source Browser:
- Browse connections
- Search objects
- Preview data
Join Operations
Creating Joins:
- Drag second source onto canvas
- Connect to existing source
- Select join type
- Configure join conditions
Join Types:
| Type | Result |
|---|---|
| Inner | Matching rows only |
| Left Outer | All left + matching right |
| Right Outer | All right + matching left |
| Full Outer | All rows from both |
| Cross | Cartesian product |
Join Conditions:
Table1.customer_id = Table2.customer_id
Table1.year = Table2.fiscal_year AND Table1.month = Table2.period
Union Operations
Creating Unions:
- Add second source
- Select union operation
- Map columns between sources
Union Types:
- Union All: Include duplicates
- Union: Remove duplicates
Filter Operations
Filter Types:
- Simple filter (column = value)
- Range filter (column BETWEEN x AND y)
- List filter (column IN (a, b, c))
- Pattern filter (column LIKE '%pattern%')
Filter Syntax:
status = 'Active'
amount >= 1000 AND amount <= 10000
region IN ('US', 'EU', 'APAC')
customer_name LIKE 'A%'
created_date IS NOT NULL
Aggregation Operations
Group By:
- Add aggregation node
- Select grouping columns
- Configure aggregate functions
Aggregate Functions:
| Function | Description |
|---|---|
| SUM | Total of values |
| AVG | Average value |
| MIN | Minimum value |
| MAX | Maximum value |
| COUNT | Row count |
| COUNT DISTINCT | Unique count |
Column Operations
Reorder Columns:
- Drag columns in output panel
- Set column order
Rename Columns:
- Click column name
- Enter new business name
Exclude Columns:
- Uncheck columns in output panel
- Hidden from downstream
Calculated Columns
Creating Calculated Columns:
- Add calculated column
- Enter expression
- Set data type
- Name column
Expression Types:
- Arithmetic:
price * quantity - String:
CONCAT(first_name, ' ', last_name) - Conditional:
CASE WHEN status = 'A' THEN 'Active' ELSE 'Inactive' END - Date:
YEAR(order_date)
Conversion Columns
Currency Conversion:
- Add currency conversion column
- Select source amount column
- Select source currency column
- Configure target currency
- Set exchange rate type
Unit Conversion:
- Add unit conversion column
- Select source quantity column
- Select source unit column
- Configure target unit
Geo Coordinates:
- Add geo coordinates column
- Select latitude/longitude columns
- Configure coordinate system
Replacing Sources
Replace Source:
- Select source node
- Choose "Replace"
- Select new source
- Remap columns
Process Source Changes:
- Detect schema changes
- Update mappings
- Handle removed columns
SQL Views
Create views using SQL or SQLScript.
Creating an SQL View
- Data Builder > New SQL View
- Write SQL statement
- Validate syntax
- Save and deploy
Language Options
| Language | Capabilities | Use Case |
|---|---|---|
| SQL (Standard Query) | SELECT with JOIN, UNION operators | Standard views |
| SQLScript (Table Function) | IF, loops, complex structures | Advanced logic |
Critical Syntax Requirements
Double Quotes Mandatory: Use double quotes for all table, column, and alias references in SELECT statements.
-- Correct
SELECT "customer_id", "customer_name" AS "name" FROM "customers"
-- Incorrect - will fail
SELECT customer_id, customer_name AS name FROM customers
LIMIT vs TOP: Use LIMIT keyword (TOP is not supported)
-- Correct
SELECT * FROM orders LIMIT 100
-- Incorrect
SELECT TOP 100 * FROM orders
Format Button: Available for SQL only (not SQLScript)
Data Preview Constraints
- Data preview unavailable when any source is cross-space shared with input parameters
- Wide tables may truncate results to prevent memory issues
Basic SQL View
SELECT
customer_id,
customer_name,
region,
country
FROM customers
WHERE active = 'Y'
SQL View with Joins
SELECT
o.order_id,
o.order_date,
c.customer_name,
p.product_name,
ol.quantity,
ol.unit_price
FROM orders o
INNER JOIN customers c ON o.customer_id = c.customer_id
INNER JOIN order_lines ol ON o.order_id = ol.order_id
INNER JOIN products p ON ol.product_id = p.product_id
SQL View with Aggregation
SELECT
customer_id,
YEAR(order_date) AS order_year,
COUNT(*) AS order_count,
SUM(order_amount) AS total_amount,
AVG(order_amount) AS avg_amount
FROM orders
GROUP BY customer_id, YEAR(order_date)
SQLScript Views
Table Variables:
DO BEGIN
lt_customers = SELECT * FROM customers WHERE region = 'US';
lt_orders = SELECT * FROM orders WHERE customer_id IN (SELECT customer_id FROM :lt_customers);
SELECT * FROM :lt_orders;
END;
Control Flow:
DO BEGIN
DECLARE lv_year INTEGER := YEAR(CURRENT_DATE);
IF :lv_year > 2024 THEN
SELECT * FROM orders WHERE order_year = :lv_year;
ELSE
SELECT * FROM archive_orders WHERE order_year = :lv_year;
END IF;
END;
Input Parameters in SQL Views
Parameter Definition:
-- Input parameter: IP_REGION (String)
SELECT *
FROM customers
WHERE region = :IP_REGION
Multiple Parameters:
-- IP_START_DATE (Date), IP_END_DATE (Date), IP_REGION (String)
SELECT *
FROM orders
WHERE order_date BETWEEN :IP_START_DATE AND :IP_END_DATE
AND region = :IP_REGION
Entity-Relationship Models
Visual data modeling with entities and associations.
Creating an E-R Model
- Data Builder > New E-R Model
- Add entities (tables/views)
- Create associations
- Save and deploy
Adding Entities
Create Table:
- Define columns
- Set primary key
- Configure properties
Create View:
- Define SELECT statement
- Configure output
Add Existing:
- Drag from repository
- Reference existing objects
Creating Associations
- Select source entity
- Draw line to target entity
- Configure join columns
- Set cardinality
Association Properties:
| Property | Options |
|---|---|
| Cardinality | 1:1, 1:n, n:1, n:m |
| Join Type | Inner, Left Outer |
| Semantic | Reference, Composition |
Adding Related Entities
Discover Related:
- Analyze existing associations
- Suggest related entities
- Auto-create associations
Intelligent Lookups
Match and enrich data using fuzzy logic when traditional joins fail due to data quality issues.
Purpose: Merge data from two entities even when problems joining them exist (unreliable foreign keys, inconsistent naming, data quality issues).
Technical Architecture
Component Structure:
- Input entity with mandatory pairing column
- Lookup entity with designated return columns
- Rule node (exact or fuzzy matching)
- Output view configuration
Pairing Column Requirements
The pairing column identifies individual records:
- Typically ID fields or unique identifiers
- Can be a calculated column concatenating multiple values
- Falls back to key column if primary identifier unavailable
Creating an Intelligent Lookup
- Data Builder > New Intelligent Lookup
- Add input entity
- Add lookup entity
- Define pairing column
- Configure match rules
- Define output
Match Rule Types
Exact Match:
rule: exact_customer_id
input_column: customer_id
lookup_column: customer_key
match_type: exact
Fuzzy Match:
rule: fuzzy_company_name
input_column: company_name
lookup_column: organization_name
match_type: fuzzy
threshold: 0.8
Fuzzy Match Configuration
| Parameter | Description | Default |
|---|---|---|
| Threshold | Match score (0-1) | 0.8 |
| Algorithm | Matching algorithm | Levenshtein |
| Case Sensitive | Match case | No |
Result Categories
Results are color-coded with percentages on rule symbols:
| Category | Color | Description | Actions |
|---|---|---|---|
| Matched | Green | Records matched against lookup data | Can reject |
| Review | Green | Fuzzy matches between review/matched thresholds | Approve or reject |
| Multiple | Yellow | Records matching 2+ lookup records | Select candidate |
| Unmatched | Red | No matching lookup record found | Manual match |
| Unprocessed | Grey | New records not processed since last run | Run lookup |
Processing Results
Matched Results:
- Single match: Auto-assign
- Multiple matches: Review/select candidates
- No match: Manual assignment
Unmatched Results:
- Create new lookup records
- Manual matching
- Skip records
Rule Management
Modification Handling:
- Modifying rules prompts deletion of subsequent results
- User-confirmed matches can be preserved or deleted
Adding Rules:
- Add Rule for Multiple Matches: Applies AND logic to narrow down candidates
- Add Rule for Unmatched Records: Targets unmatched category for re-processing
Important: Redeployment required after rule modification before re-execution
Multi-Rule Lookups
Combine multiple rules:
- Exact match on ID
- Fuzzy match on name
- Location-based match
Example: Address Enrichment
rules:
- exact: postal_code
- fuzzy: street_name (0.85)
- fuzzy: city_name (0.9)
View Operations
Saving and Deploying
Save: Store definition Deploy: Activate for use
Deployment Validation:
- Syntax check
- Dependency check
- Semantic validation
Object Dependencies
View Dependencies:
View A (deployed)
└── View B (requires A)
└── View C (requires B)
Impact Analysis:
- Find dependent objects
- Assess change impact
- Plan modifications
Lineage Analysis
Column Lineage:
- Track column origins
- Understand transformations
- Document data flow
Impact Lineage:
- Identify downstream impact
- Plan changes safely
Version Management
Version History:
- View all versions
- Compare versions
- Restore previous version
Input Parameters
Runtime parameters for dynamic filtering.
Creating Input Parameters
- Open view properties
- Add input parameter
- Configure type and default
- Use in filter/expression
Parameter Types
| Type | Use Case | Example |
|---|---|---|
| String | Text filtering | Region code |
| Integer | Numeric filtering | Year |
| Date | Date filtering | Start date |
| Timestamp | DateTime filtering | As-of timestamp |
Parameter Usage
In Filters:
WHERE region = :IP_REGION
In Expressions:
CASE WHEN year = :IP_YEAR THEN 'Current' ELSE 'Historical' END
Default Values:
parameter: IP_YEAR
type: Integer
default: YEAR(CURRENT_DATE)
Data Access Controls in Views
Apply row-level security to views.
Applying Data Access Control
- Open view properties
- Select "Data Access Control"
- Choose DAC object
- Map columns
- Deploy
DAC Integration
Criteria Mapping:
view_column: region
dac_criteria: user_region
Multiple Criteria:
mappings:
- region: user_region
- company_code: user_company
Persistence
Store view results for improved performance.
Enabling Persistence
- Open view properties
- Enable persistence
- Configure refresh schedule
- Deploy
Persistence Options
| Option | Description |
|---|---|
| Scheduled | Refresh at intervals |
| On-Demand | Manual refresh |
| Delta | Incremental refresh |
Partitioning Persisted Views
Partition by Date:
partition_column: order_date
partition_type: range
partition_function: monthly
Validation and Performance
Validating View Data
Data Preview:
- View sample data
- Check row counts
- Verify calculations
Validation Rules:
- Data type checks
- Null checks
- Business rules
Analyzing View Performance
Performance Analysis:
- Execution time
- Row counts
- Resource usage
Optimization Tips:
- Filter early
- Minimize joins
- Use appropriate indexes
- Consider persistence
SQL Reference
Common SQL Functions
String Functions:
| Function | Example |
|---|---|
| CONCAT | CONCAT(a, b) |
| SUBSTRING | SUBSTRING(s, 1, 5) |
| UPPER/LOWER | UPPER(name) |
| TRIM | TRIM(text) |
| LENGTH | LENGTH(string) |
| REPLACE | REPLACE(s, 'old', 'new') |
Numeric Functions:
| Function | Example |
|---|---|
| ROUND | ROUND(num, 2) |
| FLOOR/CEIL | FLOOR(num) |
| ABS | ABS(value) |
| MOD | MOD(a, b) |
| POWER | POWER(base, exp) |
Date Functions:
| Function | Example |
|---|---|
| YEAR | YEAR(date) |
| MONTH | MONTH(date) |
| DAY | DAY(date) |
| ADD_DAYS | ADD_DAYS(date, 7) |
| DATEDIFF | DATEDIFF(d1, d2) |
| CURRENT_DATE | CURRENT_DATE |
Conversion Functions:
| Function | Example |
|---|---|
| CAST | CAST(num AS VARCHAR) |
| TO_DATE | TO_DATE(str, 'YYYY-MM-DD') |
| TO_DECIMAL | TO_DECIMAL(str, 10, 2) |
Window Functions
-- Row number
ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_date)
-- Running total
SUM(amount) OVER (PARTITION BY customer_id ORDER BY order_date)
-- Rank
RANK() OVER (PARTITION BY region ORDER BY sales DESC)
Documentation Links
- Graphical Views: https://help.sap.com/docs/SAP_DATASPHERE/c8a54ee704e94e15926551293243fd1d/27efb47
- SQL Views: https://help.sap.com/docs/SAP_DATASPHERE/c8a54ee704e94e15926551293243fd1d/81920e4
- E-R Models: https://help.sap.com/docs/SAP_DATASPHERE/c8a54ee704e94e15926551293243fd1d/a91c042
- Intelligent Lookups: https://help.sap.com/docs/SAP_DATASPHERE/c8a54ee704e94e15926551293243fd1d/8f29f80
- SQL Reference: https://help.sap.com/docs/SAP_DATASPHERE/c8a54ee704e94e15926551293243fd1d/6a37cc5
Last Updated: 2025-11-22