P_MaterialStock_Aggr
Aggreg. of Material Stock for KPI Analysis
P_MaterialStock_Aggr is a Composite CDS View that provides data about "Aggreg. of Material Stock for KPI Analysis" in SAP S/4HANA. It reads from 1 data source (I_MaterialDocumentRecord) and exposes 21 fields with key fields Material, Plant, StorageLocation, Batch, Supplier. It has 1 association to related views. Part of development package ODATA_MM_IM_KPITIMESERIES.
Data Sources (1)
| Source | Alias | Join Type |
|---|---|---|
| I_MaterialDocumentRecord | I_MaterialDocumentRecord | from |
Associations (1)
| Cardinality | Target | Alias | Condition |
|---|---|---|---|
| [1..1] | I_UnitOfMeasure | _UnitOfMeasure | $projection.MaterialBaseUnit = _UnitOfMeasure.UnitOfMeasure |
Annotations (6)
| Name | Value | Level | Field |
|---|---|---|---|
| AccessControl.authorizationCheck | #CHECK | view | |
| ObjectModel.usageType.sizeCategory | #XXL | view | |
| ObjectModel.usageType.serviceQuality | #D | view | |
| ObjectModel.usageType.dataClass | #TRANSACTIONAL | view | |
| VDM.viewType | #COMPOSITE | view | |
| VDM.private | true | view |
Fields (21)
| Key | Field | Source Table | Source Field | Description |
|---|---|---|---|---|
| KEY | Material | StockIdentifyingMaterial | ||
| KEY | Plant | Plant | ||
| KEY | StorageLocation | |||
| KEY | Batch | StockIdentifyingBatch | ||
| KEY | Supplier | SpecialStockIdfgSupplier | ||
| KEY | SDDocument | SpecialStockIdfgSalesOrder | ||
| KEY | SDDocumentItem | SpecialStockIdfgSalesOrderItem | ||
| KEY | WBSElementInternalID | SpecialStockIdfgWBSElement | ||
| KEY | Customer | SpecialStockIdfgCustomer | ||
| KEY | SpecialStockIdfgStockOwner | SpecialStockIdfgStockOwner | ||
| KEY | InventoryStockType | InventoryStockType | ||
| KEY | InventorySpecialStockType | InventorySpecialStockType | ||
| KEY | FiscalYearVariant | FiscalYearVariant | ||
| KEY | MatlDocLatestPostgDate | PostingDate | ||
| KEY | MaterialBaseUnit | MaterialBaseUnit | ||
| KEY | CostEstimate | CostEstimate | ||
| CompanyCode | CompanyCode | |||
| Currency | CompanyCodeCurrency | |||
| MatlWrhsStkQtyInMatlBaseUnit | ||||
| MatlCnsmpnQtyInMatlBaseUnit | ||||
| _UnitOfMeasure | _UnitOfMeasure |
@AccessControl.authorizationCheck: #CHECK
@ObjectModel.usageType.sizeCategory: #XXL
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.dataClass:#TRANSACTIONAL
@VDM: {
viewType: #COMPOSITE,
private: true
}
define view entity P_MaterialStock_Aggr as select from I_MaterialDocumentRecord
association [1..1] to I_UnitOfMeasure as _UnitOfMeasure on $projection.MaterialBaseUnit = _UnitOfMeasure.UnitOfMeasure
{
// All fields have to be defined as key field and quantity/value have to be summarized on this lowest level
// in addition to the annotation for aggregation (#SUM)
// This is especiall required for consumption views used by users with restricted authorization to get the right results
// (just because right now an INNER JOIN is created which may multiply the result set and hence the aggregate is wrong)
// Stock Identifier
key StockIdentifyingMaterial as Material,
key Plant as Plant,
key cast(StockIdfgStorageLocation as lgort_d) as StorageLocation,
key StockIdentifyingBatch as Batch,
key SpecialStockIdfgSupplier as Supplier,
key SpecialStockIdfgSalesOrder as SDDocument,
key SpecialStockIdfgSalesOrderItem as SDDocumentItem,
key SpecialStockIdfgWBSElement as WBSElementInternalID,
key SpecialStockIdfgCustomer as Customer,
key SpecialStockIdfgStockOwner,
key InventoryStockType as InventoryStockType,
key InventorySpecialStockType as InventorySpecialStockType,
// Further Stock Groups
@Semantics.fiscal.yearVariant: true
key FiscalYearVariant as FiscalYearVariant,
@Semantics.businessDate.at: true
key PostingDate as MatlDocLatestPostgDate,
// Units
key MaterialBaseUnit as MaterialBaseUnit,
key CostEstimate,
CompanyCode as CompanyCode,
CompanyCodeCurrency as Currency,
// Quantities
@Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
@DefaultAggregation : #SUM
cast(sum(MatlStkChangeQtyInBaseUnit) as nsdm_stock_qty preserving type) as MatlWrhsStkQtyInMatlBaseUnit,
@Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
@DefaultAggregation : #SUM
cast(sum(MatlCnsmpnQtyInMatlBaseUnit) as nsdm_consumption_qty preserving type) as MatlCnsmpnQtyInMatlBaseUnit,
@Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
@DefaultAggregation : #SUM
cast(sum(case when MatlStkChangeQtyInBaseUnit > 0
then MatlStkChangeQtyInBaseUnit
else cast( 0 as nsdm_stock_increase_qty) end) as nsdm_stock_increase_qty preserving type) as MatlStkIncrQtyInMatlBaseUnit,
@Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
@DefaultAggregation : #SUM
cast(sum(case when MatlStkChangeQtyInBaseUnit < 0
then abs(MatlStkChangeQtyInBaseUnit)
else cast( 0 as nsdm_stock_decrease_qty) end) as nsdm_stock_decrease_qty preserving type) as MatlStkDecrQtyInMatlBaseUnit,
_UnitOfMeasure
}
where
MaterialBaseUnit <> ''
group by
StockIdentifyingMaterial,
Plant,
StockIdfgStorageLocation,
StockIdentifyingBatch,
SpecialStockIdfgSupplier,
SpecialStockIdfgSalesOrder,
SpecialStockIdfgSalesOrderItem,
SpecialStockIdfgWBSElement,
SpecialStockIdfgCustomer,
SpecialStockIdfgStockOwner,
InventoryStockType,
InventorySpecialStockType,
CompanyCode,
CompanyCodeCurrency,
FiscalYearVariant,
PostingDate,
MaterialBaseUnit,
CostEstimate
Learn More
- What Is a CDS View in SAP S/4HANA?
- Types of CDS Views: Basic, Composite, Consumption, and Transactional
- SAP Tables vs CDS Views — Key Differences
- Understanding Data Lineage in SAP S/4HANA
- VDM (Virtual Data Model) in SAP S/4HANA Explained
- CDS View Annotations — A Complete Guide
- CDS View Field Mapping and Associations
- Understanding the SAP S/4HANA Data Model
- CDS View Extensions and Custom Fields in SAP S/4HANA
- Released APIs and Stability Contracts in SAP S/4HANA