Day 11: CDS + AMDP Real-Time Scenarios

 

Day 9: AMDP Advanced Concepts

Day 10: Table Functions

Day 11: CDS + AMDP Real-Time Scenarios

  • CDS views used in Fiori List Reports

  • AMDP used in mass data reporting

  • TF used in dashboards

Practice:

  • Integrate CDS > TF > OData for real app simulation




1. How CDS Views Are Used in Fiori List Reports – In-Depth Explanation

🔹 What Is a Fiori List Report?

A Fiori List Report is a type of standard SAP Fiori application template that provides:

  • A smart filter bar

  • A list table with sorting, filtering, grouping

  • Navigation to Object Pages

🔹 Role of CDS Views

CDS views are the backbone of List Reports – the data source must be a CDS view with proper annotations.

🔹 Requirements to Use CDS in List Report

  1. Use @OData.publish: true or expose via Service Definition and Binding

  2. CDS should include UI Annotations like:

    • @UI.lineItem

    • @UI.selectionField

    • @UI.identification

    • @UI.facet, @UI.fieldGroup

✅ Sample CDS View for Fiori List Report

@AbapCatalog.sqlViewName: 'ZLISTORDERS'

@AccessControl.authorizationCheck: #CHECK

@EndUserText.label: 'Sales Order List View'

@UI.headerInfo: {

  typeName: 'Sales Order',

  typeNamePlural: 'Sales Orders',

  title: { type: #STANDARD, value: 'SalesOrder' }

}

@OData.publish: true

define view entity ZI_SalesOrderList

  as select from vbak

{

  key vbeln         as SalesOrder,

      erdat         as CreatedDate,

      auart         as OrderType,

      vkorg         as SalesOrg,


  @UI.lineItem: [{ position: 10 }]

  @UI.selectionField: [{ position: 10 }]

  erdat,


  @UI.lineItem: [{ position: 20 }]

  auart,


  @UI.lineItem: [{ position: 30 }]

  vkorg

}

🔹 Steps to Test in Fiori Launchpad:

  1. Activate CDS

  2. Use /IWFND/MAINT_SERVICE to add the service

  3. Create Fiori app with List Report template in BAS/WebIDE

  4. Bind the OData entity

  5. Run it in Launchpad – you'll get filters + table auto-generated 🎉


2. How AMDP Is Used in Mass Data Reporting – In-Depth Explanation

🔹 Why AMDP?

  • When data processing logic is complex (aggregations, nested queries, multiple joins)

  • When performance is critical (processing millions of rows)

🔹 Typical Use Case

  • Generate summarized sales orders grouped by customer, region, and month with dynamic logic.

✅ Example AMDP Class

CLASS ZCL_SALES_AGGREGATE DEFINITION

  PUBLIC

  CREATE PUBLIC.

  PUBLIC SECTION.

    INTERFACES: IF_AMDP_MARKER_HDB.


    CLASS-METHODS:

      get_sales_summary

        IMPORTING

          VALUE(iv_year) TYPE abap.numc4

        EXPORTING

          VALUE(et_data) TYPE TABLE OF zsales_summary.

ENDCLASS.


CLASS ZCL_SALES_AGGREGATE IMPLEMENTATION.

  METHOD get_sales_summary BY DATABASE PROCEDURE

                          FOR HDB

                          LANGUAGE SQLSCRIPT

                          OPTIONS READ-ONLY

                          USING vbak vbap.

    et_data = SELECT

                vbak.kunnr AS customer,

                EXTRACT(MONTH FROM vbak.erdat) AS month,

                SUM(vbap.netwr) AS total_value

              FROM vbak

              INNER JOIN vbap ON vbak.vbeln = vbap.vbeln

              WHERE EXTRACT(YEAR FROM vbak.erdat) = :iv_year

              GROUP BY vbak.kunnr, EXTRACT(MONTH FROM vbak.erdat);

  ENDMETHOD.

ENDCLASS.

Use this in a report or wrap in a CDS Table Function if needed.


3. How TF Is Used in Dashboards – In-Depth Explanation

🔹 Use Case: Dashboard

  • Dashboards in Fiori or SAP Analytics Cloud need performant real-time data.

  • CDS Table Function allows backend SQLScript to drive data into UI5 dashboard widgets.

✅ Use Case: Sales by Region

  • Custom logic in SQLScript

  • Consumed in a smart chart (Fiori Elements)

🔹 Steps:

  1. Create Table Function Interface:

define table function ZTF_SalesByRegion

  with parameters iv_year: abap.numc4

  returns {

    region:        vbak.vkbur,

    total_value:   abap.curr_17_2,

    order_count:   abap.int4

  }

  implemented by method ZCL_SALES_DASHBOARD=>get_sales_data;


  1. Implement the AMDP class with logic:

METHOD get_sales_data BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING vbak vbap.

  et_data = SELECT

              vbak.vkbur AS region,

              SUM(vbap.netwr) AS total_value,

              COUNT(DISTINCT vbak.vbeln) AS order_count

            FROM vbak

            JOIN vbap ON vbak.vbeln = vbap.vbeln

            WHERE EXTRACT(YEAR FROM vbak.erdat) = :iv_year

            GROUP BY vbak.vkbur;

ENDMETHOD.

  1. Expose via CDS view + OData + Fiori Chart App ( Refer Below Example )


4. Integrate CDS > TF > OData – Real App Simulation

🔹 Architecture:

  • CDS View → uses Table Function → published as OData → consumed in UI app (BAS / Fiori)

✅ Step-by-Step

  1. CDS Table Function and AMDP

    • SQLScript logic implemented for custom calculation (Refer Above Example)

  2. CDS Wrapper View

@EndUserText.label: 'Sales Dashboard View'

@AccessControl.authorizationCheck: #NOT_REQUIRED

@OData.publish: true

define view entity ZI_SalesDashboard

  as select from ZTF_SalesByRegion( iv_year: '2024' )

{

  region,

  total_value,

  order_count

}

  1. Service Registration

    • /IWBEP/REG_SERVICE

    • /IWFND/MAINT_SERVICE

  2. UI5 / Fiori App

    • List Report / Chart App consuming the OData

  3. Test URLs

    • .../sap/opu/odata/sap/Z_SALES_DASHBOARD_CDS/$metadata

    • .../sap/opu/odata/sap/Z_SALES_DASHBOARD_CDS/ZI_SalesDashboard?$filter=region eq 'NA'



























Day 12: Performance & Optimization

  • Explain pushdown with examples

  • Tools: ST05, SAT, Explain Plan

  • Indexing & Buffering tips

Task:

  • Compare performance: CDS vs Open SQL report



Comments

Popular posts from this blog

Day 1: Introduction to ABAP on HANA

Day 3: CDS Intermediate – Filters & Expressions

Day 2: CDS View Basics