P_PhysInvtryKeyFiguresBase

DDL: P_PHYSINVTRYKEYFIGURESBASE Type: view_entity COMPOSITE Package: ODATA_MM_IM_PI_MASS_CREATE

Basis for the calc. of PI Key Figures for a Stock Sep. Comb.

P_PhysInvtryKeyFiguresBase is a Composite CDS View that provides data about "Basis for the calc. of PI Key Figures for a Stock Sep. Comb." in SAP S/4HANA. It reads from 5 data sources (I_CompanyCode, marv, I_Plant, P_PhysIntryValuationArea, P_MappedPhysInvtryItem) and exposes 16 fields with key fields Material, Plant, StorageLocation, Batch, Supplier. Part of development package ODATA_MM_IM_PI_MASS_CREATE.

Data Sources (5)

SourceAliasJoin Type
I_CompanyCode _CompanyCode inner
marv _CurrentPeriod inner
I_Plant _Plant inner
P_PhysIntryValuationArea _ValuationArea inner
P_MappedPhysInvtryItem item from

Annotations (3)

NameValueLevelField
AccessControl.authorizationCheck #NOT_ALLOWED view
VDM.private true view
VDM.viewType #COMPOSITE view

Fields (16)

KeyFieldSource TableSource FieldDescription
KEY Material P_MappedPhysInvtryItem Material
KEY Plant P_MappedPhysInvtryItem Plant
KEY StorageLocation P_MappedPhysInvtryItem StorageLocation
KEY Batch P_MappedPhysInvtryItem Batch
KEY Supplier P_MappedPhysInvtryItem Supplier
KEY SalesOrder P_MappedPhysInvtryItem SalesOrder
KEY SalesOrderItem P_MappedPhysInvtryItem SalesOrderItem
KEY WBSElementInternalID P_MappedPhysInvtryItem WBSElementInternalID
KEY Customer P_MappedPhysInvtryItem Customer
KEY StockOwner P_MappedPhysInvtryItem StockOwner
KEY InventoryStockType P_MappedPhysInvtryItem InventoryStockType
KEY InventorySpecialStockType P_MappedPhysInvtryItem InventorySpecialStockType
KEY MaterialBaseUnit P_MappedPhysInvtryItem MaterialBaseUnit
PhysicalInventoryLastCountDate
NumberOfPhysInventoryCounts
CurrentDate
@AccessControl.authorizationCheck: #NOT_ALLOWED
@VDM.private: true
@VDM.viewType: #COMPOSITE
define view entity P_PhysInvtryKeyFiguresBase as select from P_MappedPhysInvtryItem as item

  inner join I_Plant as _Plant on item.Plant = _Plant.Plant
  inner join P_PhysIntryValuationArea as _ValuationArea on _Plant.ValuationArea = _ValuationArea.ValuationArea
  inner join I_CompanyCode as _CompanyCode on _CompanyCode.CompanyCode = _ValuationArea.CompanyCode
  inner join marv as _CurrentPeriod on _CurrentPeriod.bukrs = _ValuationArea.CompanyCode
  
//  association [0..1] to I_FiscalYear as _FiscalYear on _FiscalYear.FiscalYearVariant = _CompanyCode.FiscalYearVariant and

//                                                       _FiscalYear.FiscalYear        = _CurrentPeriod.lfgja

{
  key item.Material,
  key item.Plant,
  key item.StorageLocation,
  key item.Batch,
  key item.Supplier,
  key item.SalesOrder,
  key item.SalesOrderItem,
  key item.WBSElementInternalID,
  key item.Customer,
  key item.StockOwner,
  key item.InventoryStockType,
  key item.InventorySpecialStockType,
  key item.MaterialBaseUnit,
  
  max(item.PhysicalInventoryLastCountDate) as PhysicalInventoryLastCountDate,
  
// use check of PI Doc fiscal year and MARV current fiscal year as I_FiscalYear has performance issues  

//sum( case when _FiscalYear.FiscalYearStartDate > PhysicalInventoryLastCountDate then 0 else 1 end ) as NumberOfPhysInventoryCounts,

  sum( case when ( _CurrentPeriod.lfgja =  item.FiscalYear and item.PhysicalInventoryItemIsCounted = 'X'  ) then 1 else 0 end ) as NumberOfPhysInventoryCounts,
  
  $session.system_date as CurrentDate
  
} 
where item.PhysInvtryDifferenceIsPosted = 'X'  
group by 
  item.Material, 
  item.Plant,
  item.StorageLocation,
  item.Batch,
  item.SalesOrder,
  item.SalesOrderItem,
  item.Supplier,
  item.Customer,
  item.StockOwner,
  item.WBSElementInternalID,
  item.InventoryStockType,
  item.InventorySpecialStockType,
  item.MaterialBaseUnit