← Back to DAGDA | Support | Source: https://github.com/zpatch-bom/ABAP-CDS-training
Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

SAP ABAP Core Data Services (CDS) Training Project

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.


1. Naming Conventions

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.

2. Technical Curriculum & Object Catalog

The project is structured into logical training units, each focusing on specific SAP HANA database-pushdown features.

Unit A: Basic CDS 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.
  • Inner Joins & Session Variables: ZI_Train00_Basic_02
    • Demonstrates joining tables and utilizing built-in HANA session variables such as $session.system_date.
  • 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 JOIN checking for NULL in the matching key to filter out matching rows.
  • Literals & Domain Values: ZI_Train00_Basic_05
    • Demonstrates using character literals, integer/decimal literals, and referencing domain-fixed values (e.g., #koart.'D').

Unit B: Advanced CDS Expressions

Covers database-level functions, type conversions, and data aggregation.

  • Input Parameters: ZI_TRAIN00_ADVANCED_01
    • Demonstrates with parameters syntax and date arithmetic functions like dats_add_days().
  • 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 complex CASE statements, and declare currency semantics.
  • Quantity & Currency Semantics: ZI_Train00_Annotations_01
    • Shows semantic annotations mapping quantity and amount fields to their corresponding unit/currency keys using @Semantics.
  • 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 ...).
  • Arithmetic & Casting: ZI_Train00_More_02
    • Demonstrates calculations, division(), and cast() expressions to standard DDIC data types and data elements.
  • String Operations: ZI_Train00_More_03
    • Covers string manipulation: length(), ltrim(), rpad(), left(), right(), substring(), concat(), replace(), upper(), and lower().
  • Conversions (Currency & Unit): ZI_Train00_More_04
    • Demonstrates standard SAP conversions at database level: unit_conversion() and currency_conversion().
  • Date Operations: ZI_Train00_More_05
    • Illustrates dats_is_valid(), dats_add_days(), dats_add_months(), and dats_days_between().
  • Aggregations & Grouping: ZI_TRAIN00_MORE_07
    • Details aggregations: count(*), count(distinct ...), max(), min(), avg(), sum(), GROUP BY, and HAVING filters.
  • Set Operations (Union All): ZI_TRAIN00_MORE_08
    • Combines datasets from database views and custom tables using union all.

Unit C: Access Control (DCL)

  • 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 Code F_BKPF_BUK and Activity 03).

Unit D: View Extensions

  • 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.

Unit E: Analytical Virtual Data Model (VDM)

  • Composite/Cube Level: ZI_TRAIN00_MODEL_CUBE_01
    • Classified as @Analytics.dataCategory: #AGGREGATIONLEVEL. Defines default measures and fields utilizing aggregation annotations @Aggregation.default: #SUM.
  • 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)').

Unit F: OData & Fiori Elements Integration

  • 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 @UI position annotations, and mapping entity set names.

3. ABAP Integration & Consumption

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):

  1. Open SQL Selection: ztrain00_cds_01
    • Demonstrates standard Open SQL statements selecting directly from a CDS view.
  2. ALV IDA with Range Filters: ztrain00_cds_02
    • Shows using cl_salv_gui_table_ida=>create_for_cds_view to render data and applying user filter options via range collectors (cl_salv_range_tab_collector) and condition factories.
  3. 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 ).
  4. 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.

4. Performance Optimization: ABAP SQL Golden Rules

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 WHERE conditions.
  • 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 FIELDS clause.
  • 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).
  • Rule 4: Minimize Data Transfers (Joins vs. Loop Selects)
    • DON'T: Performing multiple database selects inside loops or utilizing FOR ALL ENTRIES followed by manual READ TABLE lookups.
    • DO: Executing a database INNER JOIN in a single query to retrieve unified relational datasets.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages