This repository serves as a comprehensive, structured hands-on training curriculum for learning and mastering SAP ABAP Core Data Services (CDS), Access Control (DCL), Analytical Modeling (VDM), OData Service Generation, and ABAP Integration (Open SQL & ALV IDA). It also highlights ABAP SQL Golden Rules for performance optimization.
The repository follows a clean, VDM-compliant naming convention for ABAP CDS entities and dictionary artifacts:
| Pattern | Component | Classification | Description / Purpose |
|---|---|---|---|
ZI_[Module]_[Description] |
Interface View | #BASIC / #COMPOSITE |
Reusable, system-independent views directly mapping tables/views. Contains joins and calculations. |
ZC_[Module]_[Description] |
Consumption View | #CONSUMPTION |
End-user query views containing UI/OData annotations. Consumed by Fiori apps or ALV IDA. |
ZP_[Module]_[Description] |
Private View | internal | Auxiliary or private views designed for modularization and internal calculation. |
ZX_[Module]_[Description] |
Interface Extension | Extension | View extensions extending existing interface views. |
ZXC_[Module]_[Description] |
Consumption Extension | Extension | View extensions extending consumption/query views. |
The project is structured into logical training units, each focusing on specific SAP HANA database-pushdown features.
Focuses on basic data selection, joining, session variables, and literals.
- Simple Selections & Annotations: ZI_Train00_Basic_01
- Demonstrates basic syntax, SQL view names (
@AbapCatalog.sqlViewName), caching optimization (@AbapCatalog.compiler.compareFilter), authorization check strategies, and semantic labeling.
- Demonstrates basic syntax, SQL view names (
- Inner Joins & Session Variables: ZI_Train00_Basic_02
- Demonstrates joining tables and utilizing built-in HANA session variables such as
$session.system_date.
- Demonstrates joining tables and utilizing built-in HANA session variables such as
- Left Outer Joins & Conditional Joins: ZI_Train00_Basic_03
- Demonstrates LEFT OUTER JOINs and specifying filtering conditions inside the JOIN clause vs. the WHERE clause.
- Anti-Joins & Exclusions (NULL check): ZI_TRAIN00_BASIC_04
- Illustrates anti-joins using
LEFT OUTER JOINchecking forNULLin the matching key to filter out matching rows.
- Illustrates anti-joins using
- Literals & Domain Values: ZI_Train00_Basic_05
- Demonstrates using character literals, integer/decimal literals, and referencing domain-fixed values (e.g.,
#koart.'D').
- Demonstrates using character literals, integer/decimal literals, and referencing domain-fixed values (e.g.,
Covers database-level functions, type conversions, and data aggregation.
- Input Parameters: ZI_TRAIN00_ADVANCED_01
- Demonstrates
with parameterssyntax and date arithmetic functions likedats_add_days().
- Demonstrates
- Parameter Passing & Case Expressions: ZI_TRAIN00_ADVANCED_02
- Shows how to pass parameters to underlying CDS views, specify default parameter values (
@Environment.systemField: #SYSTEM_DATE), write complexCASEstatements, and declare currency semantics.
- Shows how to pass parameters to underlying CDS views, specify default parameter values (
- Quantity & Currency Semantics: ZI_Train00_Annotations_01
- Shows semantic annotations mapping quantity and amount fields to their corresponding unit/currency keys using
@Semantics.
- Shows semantic annotations mapping quantity and amount fields to their corresponding unit/currency keys using
- Case Statements (Simple vs. Searched): ZI_Train00_More_01
- Contrasts Simple CASE (
case field when val then ...) with Searched CASE (case when field >= val then ...).
- Contrasts Simple CASE (
- Arithmetic & Casting: ZI_Train00_More_02
- Demonstrates calculations,
division(), andcast()expressions to standard DDIC data types and data elements.
- Demonstrates calculations,
- String Operations: ZI_Train00_More_03
- Covers string manipulation:
length(),ltrim(),rpad(),left(),right(),substring(),concat(),replace(),upper(), andlower().
- Covers string manipulation:
- Conversions (Currency & Unit): ZI_Train00_More_04
- Demonstrates standard SAP conversions at database level:
unit_conversion()andcurrency_conversion().
- Demonstrates standard SAP conversions at database level:
- Date Operations: ZI_Train00_More_05
- Illustrates
dats_is_valid(),dats_add_days(),dats_add_months(), anddats_days_between().
- Illustrates
- Aggregations & Grouping: ZI_TRAIN00_MORE_07
- Details aggregations:
count(*),count(distinct ...),max(),min(),avg(),sum(),GROUP BY, andHAVINGfilters.
- Details aggregations:
- Set Operations (Union All): ZI_TRAIN00_MORE_08
- Combines datasets from database views and custom tables using
union all.
- Combines datasets from database views and custom tables using
- Row-Level Authorizations: zc_train00_advanced_03.dcls.asdcls
- Demonstrates defining Access Control lists (DCL) mapping CDS selection fields to SAP PFCG authorization objects via
aspect pfcg_auth(e.g. restricting data access by Company CodeF_BKPF_BUKand Activity03).
- Demonstrates defining Access Control lists (DCL) mapping CDS selection fields to SAP PFCG authorization objects via
- Enhancement Categories & View Extension:
- Base view ZI_TRAIN00_ADVANCED_03 enables extension capabilities using
@AbapCatalog.viewEnhancementCategory: [#PROJECTION_LIST, #GROUP_BY]. - Extension ZX_TRAIN00_ADVANCED_03 appends custom fields and associations using
extend view ... with .... - Consumption Extension ZXC_TRAIN00_ADVANCED_03 projects the extended fields to the consumption layer.
- Base view ZI_TRAIN00_ADVANCED_03 enables extension capabilities using
- Composite/Cube Level: ZI_TRAIN00_MODEL_CUBE_01
- Classified as
@Analytics.dataCategory: #AGGREGATIONLEVEL. Defines default measures and fields utilizing aggregation annotations@Aggregation.default: #SUM.
- Classified as
- Consumption Query Level: ZC_TRAIN00_MODEL_Query_01
- Defines multidimensional reporting configurations: axes placement (
@AnalyticsDetails.query.axis), display formats (#KEY_TEXT), totals display, and complex formula columns calculated on the database (e.g.@AnalyticsDetails.query.formula: 'NDIV0( overDue * 100 / openingAmount)').
- Defines multidimensional reporting configurations: axes placement (
- OData Service Exposure: ZC_TRAIN00_MODEL_QUERY_04
- Demonstrates exposing CDS views directly to the SAP Gateway using
@OData.publish: true, configuring UI layouts with@UIposition annotations, and mapping entity set names.
- Demonstrates exposing CDS views directly to the SAP Gateway using
The repository contains ABAP executable programs illustrating how to select from and display CDS view content using both Open SQL and ALV with Integrated Data Access (ALV IDA):
- Open SQL Selection: ztrain00_cds_01
- Demonstrates standard Open SQL statements selecting directly from a CDS view.
- ALV IDA with Range Filters: ztrain00_cds_02
- Shows using
cl_salv_gui_table_ida=>create_for_cds_viewto render data and applying user filter options via range collectors (cl_salv_range_tab_collector) and condition factories.
- Shows using
- Selecting from Parameterized Views: ztrain00_cds_03
- Shows selecting from a parameterized CDS view inside Open SQL using parenthetical parameter bindings:
zi_train00_advanced_01( i_days_1 = @p_days_1 ).
- Shows selecting from a parameterized CDS view inside Open SQL using parenthetical parameter bindings:
- ALV IDA Parameter Passing & Layouts: ztrain00_cds_04
- Illustrates ALV IDA consumption of parameterized CDS views by providing parameter mappings via
set_view_parameters()and configuring sort/aggregation layouts.
- Illustrates ALV IDA consumption of parameterized CDS views by providing parameter mappings via
The class zcltrain_golden_rules contains code patterns demonstrating critical SAP HANA performance practices by contrasting low-performing "DON'T" practices with optimized "DO" practices:
SAP HANA SQL PERFORMANCE RULES
DON'T (Application Loop Processing) DO (Database Pushdown Optimization)
┌──────────────────────────────────────┐ ┌──────────────────────────────────────┐
│ - Select non-filtered records │ │ - Filter result sets early in WHERE │
│ - Loop over table & check criteria │ │ - Minimize transferred data fields │
│ - Select * (entire structure) │ │ - Push aggregation/sums to DB layer │
│ - Collect/aggregate in loop │ │ - Use INNER JOIN instead of loops or │
│ - Nested loops or FOR ALL ENTRIES │ │ FOR ALL ENTRIES │
└──────────────────────────────────────┘ └──────────────────────────────────────┘
- Rule 1: Keep Result Sets Small
- DON'T: Selecting a wide dataset and doing
LOOP AT ... CHECK ...filter checks in the ABAP application server layer. - DO: Offloading the filter directly to the database layer via proper
WHEREconditions.
- DON'T: Selecting a wide dataset and doing
- Rule 2: Minimize Transferred Data
- DON'T: Selecting all fields using
SELECT *when only a few columns are needed. - DO: Specifying only the required fields in the
FIELDSclause.
- DON'T: Selecting all fields using
- Rule 3: Database Aggregations
- DON'T: Pulling raw rows to the application server and loop-aggregating using
COLLECT. - DO: Utilizing HANA database aggregate functions (
SUM(),GROUP BY,HAVING) and conditional sum logic (CASE).
- DON'T: Pulling raw rows to the application server and loop-aggregating using
- Rule 4: Minimize Data Transfers (Joins vs. Loop Selects)
- DON'T: Performing multiple database selects inside loops or utilizing
FOR ALL ENTRIESfollowed by manualREAD TABLElookups. - DO: Executing a database
INNER JOINin a single query to retrieve unified relational datasets.
- DON'T: Performing multiple database selects inside loops or utilizing