P_MaterialStockAggrMvt
P_MaterialStockAggrMvt is a Composite CDS View in SAP S/4HANA. It reads from 1 data source (I_MaterialDocumentRecord) and exposes 25 fields with key fields Material, Plant, StorageLocation, Batch, Supplier. It has 1 association to related views.
Data Sources (1)
| Source | Alias | Join Type |
|---|---|---|
| I_MaterialDocumentRecord | I_MaterialDocumentRecord | from |
Parameters (1)
| Name | Type | Default |
|---|---|---|
| P_InventoryConsumptionGroup | inventory_consumption_group |
Associations (1)
| Cardinality | Target | Alias | Condition |
|---|---|---|---|
| [1..1] | I_UnitOfMeasure | _UnitOfMeasure | $projection.MaterialBaseUnit = _UnitOfMeasure.UnitOfMeasure |
Annotations (10)
| Name | Value | Level | Field |
|---|---|---|---|
| AbapCatalog.preserveKey | true | view | |
| AbapCatalog.sqlViewName | PMATSTOCKAGGRMVT | view | |
| AbapCatalog.compiler.compareFilter | true | view | |
| AccessControl.authorizationCheck | #CHECK | view | |
| ObjectModel.usageType.sizeCategory | #XXL | view | |
| ObjectModel.usageType.serviceQuality | #D | view | |
| ObjectModel.usageType.dataClass | #TRANSACTIONAL | view | |
| ClientHandling.algorithm | #SESSION_VARIABLE | view | |
| VDM.viewType | #COMPOSITE | view | |
| VDM.private | true | view |
Fields (25)
| Key | Field | Source Table | Source Field | Description |
|---|---|---|---|---|
| KEY | Material | StockIdentifyingMaterial | Stock Mat. | |
| KEY | Plant | Plant | Valuation Area | |
| KEY | StorageLocation | Stor. Location SID | ||
| KEY | Batch | StockIdentifyingBatch | Batch SID | |
| KEY | Supplier | SpecialStockIdfgSupplier | Supplier SID | |
| KEY | SDDocument | SpecialStockIdfgSalesOrder | Stock Ident Header | |
| KEY | SDDocumentItem | SpecialStockIdfgSalesOrderItem | Stock Ident Item | |
| KEY | WBSElementInternalID | SpecialStockIdfgWBSElement | WBS Internal ID | |
| KEY | Customer | SpecialStockIdfgCustomer | Customer SID | |
| KEY | SpecialStockIdfgStockOwner | SpecialStockIdfgStockOwner | ||
| KEY | InventoryStockType | InventoryStockType | Stock Type | |
| KEY | InventorySpecialStockType | InventorySpecialStockType | Special Stock Type | |
| KEY | FiscalYearVariant | FiscalYearVariant | FY Variant | |
| KEY | MatlDocLatestPostgDate | PostingDate | Posting Date for GR | |
| KEY | MaterialBaseUnit | MaterialBaseUnit | Valuation Unit | |
| KEY | CostEstimate | CostEstimate | Cost EstimateNo | |
| KEY | GoodsMovementType | GoodsMovementType | Movement Type | |
| InventoryConsumptionGroup | ||||
| CompanyCode | CompanyCode | Receiver Company Code | ||
| Currency | CompanyCodeCurrency | Local Currency | ||
| MatlWrhsStkQtyInMatlBaseUnit | ||||
| MatlCnsmpnQtyInMatlBaseUnit | ||||
| MatlStkIncrQtyInMatlBaseUnit | ||||
| MatlStkDecrQtyInMatlBaseUnit | ||||
| _UnitOfMeasure | _UnitOfMeasure |
Derived SQL interpretation, reconstructed from the parsed view metadata (data sources, associations, and field mappings). SAP annotations are omitted and the structure is reformulated as SQL — this is a functional approximation, not the verbatim SAP source.
-- Derived SQL interpretation of CDS view P_MaterialStockAggrMvt.
-- Reconstructed from parsed metadata (data sources, associations, fields).
-- SAP annotations are omitted and the structure is reformulated as SQL;
-- this is a functional approximation, not the verbatim SAP source. Some join
-- conditions may be unavailable and a few CDS constructs are kept as-is.
-- SQL view name: PMATSTOCKAGGRMVT
-- Parameters: P_InventoryConsumptionGroup : inventory_consumption_group
CREATE VIEW P_MaterialStockAggrMvt AS
SELECT
StockIdentifyingMaterial AS Material,
Plant,
cast(StockIdfgStorageLocation as lgort_d) AS StorageLocation,
StockIdentifyingBatch AS Batch,
SpecialStockIdfgSupplier AS Supplier,
SpecialStockIdfgSalesOrder AS SDDocument,
SpecialStockIdfgSalesOrderItem AS SDDocumentItem,
SpecialStockIdfgWBSElement AS WBSElementInternalID,
SpecialStockIdfgCustomer AS Customer,
SpecialStockIdfgStockOwner,
InventoryStockType,
InventorySpecialStockType,
FiscalYearVariant,
PostingDate AS MatlDocLatestPostgDate,
MaterialBaseUnit,
CostEstimate,
GoodsMovementType,
$parameters.P_InventoryConsumptionGroup AS InventoryConsumptionGroup,
CompanyCode,
CompanyCodeCurrency AS Currency,
cast(sum(MatlStkChangeQtyInBaseUnit) as nsdm_stock_qty preserving type) AS MatlWrhsStkQtyInMatlBaseUnit,
cast(sum(MatlCnsmpnQtyInMatlBaseUnit) as nsdm_consumption_qty preserving type) AS MatlCnsmpnQtyInMatlBaseUnit,
cast(sum(case when MatlStkChangeQtyInBaseUnit > 0 then MatlStkChangeQtyInBaseUnit else 0 end) as nsdm_stock_increase_qty preserving type) AS MatlStkIncrQtyInMatlBaseUnit,
cast(sum(case when MatlStkChangeQtyInBaseUnit < 0 then abs(MatlStkChangeQtyInBaseUnit) else 0 end) as nsdm_stock_decrease_qty preserving type) AS MatlStkDecrQtyInMatlBaseUnit
FROM I_MaterialDocumentRecord
LEFT OUTER JOIN I_UnitOfMeasure AS _UnitOfMeasure ON MaterialBaseUnit = _UnitOfMeasure.UnitOfMeasure -- association [1..1]
;
Learn More
- VDM (Virtual Data Model) in SAP S/4HANA Explained
- Types of CDS Views: Basic, Composite, Consumption, and Transactional
- CDS View Annotations — A Complete Guide
- What Is a CDS View in SAP S/4HANA?
- SAP Tables vs CDS Views — Key Differences
- Understanding Data Lineage in SAP S/4HANA
- 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
- BSEG to ACDOCA: The Universal Journal Migration
- Business Partner Migration: KNA1/LFA1 to BUT000
- Material Document Migration: MSEG/MKPF to MATDOC
- How to Find the Right CDS View for an SAP Table
- BW Extractor to CDS View Migration Guide
- S/4HANA CDS View Deprecation: What You Need to Know
- ABAP CDS View Tutorial — From Basics to Real-World Examples
- RAP and CDS Views — Building Transactional Apps in SAP S/4HANA
- Sales Document Status Migration: VBUP/VBUK Removal in S/4HANA
- CO Tables in S/4HANA: COEP, COBK, COSS, COSP to ACDOCA