I_MatlDocWeightedStock
Weighted stock for average calc
I_MatlDocWeightedStock is a Composite CDS View that provides data about "Weighted stock for average calc" in SAP S/4HANA. It reads from 1 data source (I_MaterialDocumentRecord) and exposes 23 fields with key fields StockIdentifyingMaterial, Plant, MaterialDocumentYear, MaterialDocument, MaterialDocumentItem. It has 1 association to related views. Part of development package MM_IM_VDM_STOCK.
Data Sources (1)
| Source | Alias | Join Type |
|---|---|---|
| I_MaterialDocumentRecord | I_MaterialDocumentRecord | from |
Parameters (2)
| Name | Type | Default |
|---|---|---|
| P_StartDate | sydate | |
| P_EndDate | sydate |
Associations (1)
| Cardinality | Target | Alias | Condition |
|---|---|---|---|
| [0..1] | I_Purreqvaluationarea | _ValuationArea | $projection.valuationarea = _ValuationArea.ValuationArea |
Annotations (8)
| Name | Value | Level | Field |
|---|---|---|---|
| AccessControl.authorizationCheck | #NOT_REQUIRED | view | |
| ObjectModel.usageType.sizeCategory | #XXL | view | |
| ObjectModel.usageType.serviceQuality | #B | view | |
| ObjectModel.usageType.dataClass | #TRANSACTIONAL | view | |
| EndUserText.label | Weighted stock for average calc | view | |
| VDM.private | false | view | |
| VDM.viewType | #COMPOSITE | view | |
| VDM.lifecycle.contract.type | #SAP_INTERNAL_API | view |
Fields (23)
| Key | Field | Source Table | Source Field | Description |
|---|---|---|---|---|
| KEY | StockIdentifyingMaterial | StockIdentifyingMaterial | ||
| KEY | Plant | Plant | ||
| KEY | MaterialDocumentYear | MaterialDocumentYear | ||
| KEY | MaterialDocument | MaterialDocument | ||
| KEY | MaterialDocumentItem | MaterialDocumentItem | ||
| KEY | InventorySpecialStockType | InventorySpecialStockType | ||
| KEY | InventoryStockType | InventoryStockType | ||
| KEY | CostEstimate | CostEstimate | ||
| CompanyCode | CompanyCode | |||
| InventoryValuationType | InventoryValuationType | |||
| PostingDate | PostingDate | |||
| GoodsMovementType | GoodsMovementType | |||
| ReversedMaterialDocument | ReversedMaterialDocument | |||
| GoodsMovementIsCancelled | GoodsMovementIsCancelled | |||
| GoodsMovementCancellationType | GoodsMovementCancellationType | |||
| ValuationArea | ||||
| MaterialBaseUnit | MaterialBaseUnit | |||
| 5StartDateassumedatearlymorning | ||||
| fltpendasWgtdPerdStkChgQtyInBaseUnit | ||||
| _Plant | _Plant | |||
| _ValuationArea | _ValuationArea | |||
| _MaterialBaseUnit | _MaterialBaseUnit | |||
| _CompanyCode | _CompanyCode |
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ObjectModel.usageType.sizeCategory: #XXL
@ObjectModel.usageType.serviceQuality: #B
@ObjectModel.usageType.dataClass:#TRANSACTIONAL
@EndUserText.label: 'Weighted stock for average calc'
@VDM: {
private: false,
viewType: #COMPOSITE,
lifecycle.contract.type: #SAP_INTERNAL_API
}
define view entity I_MatlDocWeightedStock
with parameters
P_StartDate: sydate,
@Environment.systemField: #SYSTEM_DATE
P_EndDate: sydate
as select from I_MaterialDocumentRecord
association [0..1] to I_Purreqvaluationarea as _ValuationArea on $projection.valuationarea = _ValuationArea.ValuationArea
{
key StockIdentifyingMaterial,
key Plant,
key MaterialDocumentYear,
key MaterialDocument,
key MaterialDocumentItem,
key InventorySpecialStockType,
key InventoryStockType,
key CostEstimate,
CompanyCode,
InventoryValuationType,
PostingDate,
GoodsMovementType,
ReversedMaterialDocument,
GoodsMovementIsCancelled,
GoodsMovementCancellationType,
I_MaterialDocumentRecord._Plant.ValuationArea,
MaterialBaseUnit,
-- how much weighted time has the posting be effective within the period?
-- postings assumed at noon --> 0.5
-- StartDate assumed at early morning, EndDate assumed at late evening --> 1
-- Perform aggration on top of this view and calculate the SUM over the
-- weighted property PeriodWeightedStockQuantity to get the average stock
-- quantity for the aggregation level and the defined period.
-- This allows HANA to calculate the Average Stock Quantity in linear time.
@DefaultAggregation:#NONE
@Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
case
when PostingDate < $parameters.P_StartDate then cast(MatlStkChangeQtyInBaseUnit as abap.fltp)
when PostingDate > $parameters.P_EndDate then cast(0 as abap.fltp)
else cast(MatlStkChangeQtyInBaseUnit as abap.fltp)
* (1.0 + cast(dats_days_between(PostingDate, $parameters.P_EndDate) as abap.fltp))
/ (1.0 + cast(dats_days_between($parameters.P_StartDate, $parameters.P_EndDate) as abap.fltp))
end as WgtdPerdStkChgQtyInBaseUnit,
_Plant,
_ValuationArea,
_MaterialBaseUnit,
_CompanyCode
}
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