P_PhysInvtryKeyFiguresBase

DDL: P_PHYSINVTRYKEYFIGURESBASE SQL: PPIKEYFIGBASE Type: view COMPOSITE

P_PhysInvtryKeyFiguresBase is a Composite CDS View 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.

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 (7)

NameValueLevelField
AbapCatalog.preserveKey true view
AbapCatalog.sqlViewName PPIKEYFIGBASE view
AbapCatalog.compiler.compareFilter true view
AccessControl.authorizationCheck #NOT_ALLOWED view
ClientHandling.algorithm #SESSION_VARIABLE view
VDM.private true view
VDM.viewType #COMPOSITE view

Fields (16)

KeyFieldSource TableSource FieldDescription
KEY Material Material
KEY Plant P_MappedPhysInvtryItem Plant
KEY StorageLocation StorageLocation
KEY Batch Batch
KEY Supplier Supplier
KEY SalesOrder SalesOrder
KEY SalesOrderItem SalesOrderItem
KEY WBSElementInternalID WBSElementInternalID
KEY Customer Customer
KEY StockOwner StockOwner
KEY InventoryStockType InventoryStockType
KEY InventorySpecialStockType InventorySpecialStockType
KEY MaterialBaseUnit MaterialBaseUnit
PhysicalInventoryLastCountDate
NumberOfPhysInventoryCounts
CurrentDate
@AbapCatalog.preserveKey: true
@AbapCatalog.sqlViewName: 'PPIKEYFIGBASE'

@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_ALLOWED
@ClientHandling.algorithm: #SESSION_VARIABLE

@VDM.private: true
@VDM.viewType: #COMPOSITE
define view 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 Material,
  key item.Plant,
  key StorageLocation,
  key Batch,
  key Supplier,
  key SalesOrder,
  key SalesOrderItem,
  key WBSElementInternalID,
  key Customer,
  key StockOwner,
  key InventoryStockType,
  key InventorySpecialStockType,
  key MaterialBaseUnit,
  
  max(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 
  Material, 
  item.Plant,
  StorageLocation,
  Batch,
  SalesOrder,
  SalesOrderItem,
  Supplier,
  Customer,
  StockOwner,
  WBSElementInternalID,
  InventoryStockType,
  InventorySpecialStockType,
  MaterialBaseUnit