P_ENHPHYSINVTRYACTVSTKSEPVAL

CDS View

Active stock separators for which a PI count can be done

P_ENHPHYSINVTRYACTVSTKSEPVAL is a CDS View in S/4HANA. Active stock separators for which a PI count can be done. It contains 34 fields. 3 CDS views read from this table.

CDS Views using this table (3)

ViewTypeJoinVDMDescription
C_PhysInvtryProposal view_entity from CONSUMPTION Proposals for new PI counts
P_PhysInventorySituation view_entity left_outer COMPOSITE Physical Inventory Situation
P_PhysInvtryProposal view_entity from CONSUMPTION Proposals for new PI documents

Fields (34)

KeyField CDS FieldsUsed in Views
KEY Customer Customer 2
KEY InventorySpecialStockType InventorySpecialStockType 2
KEY InventoryStockType InventoryStockType 2
KEY Material Material 2
KEY MaterialBaseUnit MaterialBaseUnit 2
KEY MaterialIsPostedToStock MaterialIsPostedToStock 2
KEY Plant Plant 2
KEY RealProductBatch Batch 2
KEY SalesOrder SalesOrder 2
KEY SalesOrderItem SalesOrderItem 2
KEY StockOwner StockOwner 2
KEY StorageLocation StorageLocation 2
KEY Supplier Supplier 2
KEY WBSElement WBSElement 2
Batch SearchForBatch 1
CompanyCodeCurrency CompanyCodeCurrency 2
CycleCountType CycleCountType 2
GdsIssQtySinceLastCountInBsUnt GdsIssQtySinceLastCountInBsUnt 3
GdsRcptQtySinceLastCtInBsUnt GdsRcptQtySinceLastCtInBsUnt 3
NmbrOfDaysSinceLastPInvCount NmbrOfDaysSinceLastPInvCount 2
NmbrOfPhysInvtryPerFiscalYear NmbrOfPhysInvtryPerFiscalYear 2
NrOfGdsRcptSinceLastPInvCount NrOfGdsRcptSinceLastPInvCount 3
NrOfGoodsIssSinceLastPInvCount NrOfGoodsIssSinceLastPInvCount 3
NumberOfPhysInventoryCounts NumberOfPhysInventoryCounts 3
NumberOfPInvAdjustmentsPerYear NumberOfPInvAdjustmentsPerYear 3
PhysicalInventoryItemIsCounted PhysicalInventoryItemIsCounted 2
PhysicalInventoryLastCountDate PhysicalInventoryLastCountDate 2
PhysInvtryFloatTimeCycCounting PhysInvtryFloatTimeCycCounting 2
PhysInvtryIntvlForCycCounting PhysInvtryIntvlForCycCounting 2
PInvDiffQtyPerYearInBaseUnit PInvDiffQtyPerYearInBaseUnit 3
ProductGroup ProductGroup 2
ProductType ProductType 2
SearchForValuationType SearchForValuationType 1
WBSElementInternalID WBSElementInternalID 2
@AccessControl.authorizationCheck: #NOT_ALLOWED
@VDM.private: true
@VDM.viewType: #COMPOSITE
define view entity P_EnhPhysInvtryActvStkSepVal
  as select from           P_EnhPhysInvtryActvStkSep                                      as sep

    left outer join        P_PhysInvtryDocItemPerYear(P_StartDate: $session.system_date ) as _PIPerYear on  _PIPerYear.Material                  = sep.Material
                                                                                                        and _PIPerYear.Plant                     = sep.Plant
                                                                                                        and _PIPerYear.StorageLocation           = sep.StorageLocation
                                                                                                        and _PIPerYear.Batch                     = sep.Batch
                                                                                                        and _PIPerYear.Supplier                  = sep.Supplier
                                                                                                        and _PIPerYear.SalesOrder                = sep.SalesOrder
                                                                                                        and _PIPerYear.SalesOrderItem            = sep.SalesOrderItem
                                                                                                        and _PIPerYear.WBSElementInternalID      = sep.WBSElementInternalID
                                                                                                        and _PIPerYear.Customer                  = sep.Customer
                                                                                                        and _PIPerYear.StockOwner                = sep.StockOwner
                                                                                                        and _PIPerYear.InventoryStockType        = sep.InventoryStockType
                                                                                                        and _PIPerYear.InventorySpecialStockType = sep.InventorySpecialStockType

    left outer to one join I_BatchPlant                                                   as batch      on  sep.Material = batch.Material
                                                                                                        and sep.Plant    = batch.Plant
                                                                                                        and sep.Batch    = batch.Batch
    left outer to one join I_WBSElement                                                   as wbs        on sep.WBSElementInternalID = wbs.WBSElementInternalID
    left outer to one join I_SalesDocumentItemBasic                                       as sd         on  sep.SalesOrder     = sd.SalesDocument
                                                                                                        and sep.SalesOrderItem = sd.SalesDocumentItem
                                                                                                        
    association [0..1] to I_ProductPlantBasic         as _ProductPlantBasic           on  $projection.Material = _ProductPlantBasic.Product
                                                                                      and $projection.Plant    = _ProductPlantBasic.Plant                                                                                                    

{
      //===============================================================================================

      // Stock Separators

      //===============================================================================================

  key cast(sep.Material as matnr preserving type)                        as Material,
  key sep.Plant,
  key cast(sep.StorageLocation as pi_storage_location preserving type)   as StorageLocation,
  key sep.Batch                                                          as Batch,  
  key sep.Supplier                                                       as Supplier,
  key sep.SalesOrder                                                     as SalesOrder,
  key sep.SalesOrderItem                                                 as SalesOrderItem,
  key sep.WBSElement,
  key sep.Customer                                                       as Customer,
  key sep.StockOwner                                                     as StockOwner,
  key sep.InventoryStockType,
  key sep.InventorySpecialStockType,
  key sep.MaterialBaseUnit,
  key sep.MaterialIsPostedToStock, 
  cast( 
    case when ( _ProductPlantBasic.ValuationCategory <> '' and _ProductPlantBasic.IsBatchManagementRequired = '' )
    then ( '' )
    else ( sep.Batch ) end
  as charg_d ) as RealProductBatch, 

      sep.CycleCountType,
      sep.NmbrOfPhysInvtryPerFiscalYear,
      sep.PhysInvtryIntvlForCycCounting,
      sep.PhysInvtryFloatTimeCycCounting,

      sep.WBSElementInternalID,

      //===============================================================================================

      // Fields from product master data

      //===============================================================================================

      sep.ProductType,
      sep.ProductGroup,

      //===============================================================================================

      // Fields from plant/company master data

      //===============================================================================================

      sep.CompanyCodeCurrency,

      //===============================================================================================

      // Quantities

      //===============================================================================================

      @Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit' 
      sep.MatlWrhsStkQtyInMatlBaseUnit,

      //===============================================================================================

      // Valuation relevant keys

      //===============================================================================================

      case
        when ( sep.InventorySpecialStockType = 'E' or sep.InventorySpecialStockType = 'F' ) and sd.InventorySpecialStockValnType = 'M' then sep.SalesOrder
        else ''
      end                                                                as SalesOrderVal,
      case
        when ( sep.InventorySpecialStockType = 'E' or sep.InventorySpecialStockType = 'F' ) and sd.InventorySpecialStockValnType = 'M' then sep.SalesOrderItem
        else '000000'
      end                                                                as SalesOrderItemVal,
      case
        when ( sep.InventorySpecialStockType = 'Q' or sep.InventorySpecialStockType = 'R' ) and wbs.InventorySpecialStockValnType = 'M' then sep.WBSElementInternalID
        else '00000000'
      end                                                                as WBSElementInternalIDVal,
      case
        when ( ( sep.InventorySpecialStockType = 'E' or sep.InventorySpecialStockType = 'F' ) and sd.InventorySpecialStockValnType = 'M' ) then 'E'
        when ( ( sep.InventorySpecialStockType = 'Q' or sep.InventorySpecialStockType = 'R' ) and wbs.InventorySpecialStockValnType = 'M' ) then 'Q'
        else ''
      end                                                                as InventorySpecialStockTypeVal, //sobkz

      coalesce(batch.InventoryValuationType, '')                         as InventoryValuationType, //bwtar

      batch.InventoryValuationType as SearchForValuationType,
      case
        when sep.InventorySpecialStockType = 'Q' or sep.InventorySpecialStockType = 'R' then wbs.InventorySpecialStockValnType
        when sep.InventorySpecialStockType = 'E' or sep.InventorySpecialStockType = 'F' then sd.InventorySpecialStockValnType
        else ''
      end                                                                as InventorySpecialStockValnType, //kzbws

      sep.PhysicalInventoryLastCountDate,
      sep.NumberOfPhysInventoryCounts,
      sep.NmbrOfDaysSinceLastPInvCount,
      sep.PhysicalInventoryItemIsCounted,
      @Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit' 
      cast(sep.GdsIssQtySinceLastCountInBsUnt as pi_gi_qty_since_last_cnt)   as GdsIssQtySinceLastCountInBsUnt,
      FLTP_TO_DEC( sep.AvgStkQtySinceLastCountCorrect as abap.dec(31,14) )   as AvgStkQtySinceLastCountCorrect,
      //  FLTP_TO_DEC( AvgStkQtySinceLastCountCorrect as abap.dec(27,5) ) as AvgStkQtySinceLastCountCorrect,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      _PIPerYear.DifferenceAmtPerYrInCoCodeCrcy,
      cast(sep.NrOfGdsMvtSinceLastPInvCnt as pi_nr_of_gm_since_last_cnt)     as NrOfGdsMvtSinceLastPInvCnt,
      cast(_PIPerYear.NumberOfPInvAdjustmentsPerYear as pi_nr_of_adjstmnt_per_year) as NumberOfPInvAdjustmentsPerYear,
      @Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
      cast(_PIPerYear.PInvDiffQtyPerYearInBaseUnit as pi_difference_qty_per_year)   as PInvDiffQtyPerYearInBaseUnit,
      cast(sep.NrOfGdsRcptSinceLastPInvCount as pi_nr_of_gr_since_last_cnt)  as NrOfGdsRcptSinceLastPInvCount,
      @Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit' 
      cast(sep.GdsRcptQtySinceLastCtInBsUnt as pi_gr_qty_since_last_cnt)     as GdsRcptQtySinceLastCtInBsUnt,
      cast(sep.NrOfGoodsIssSinceLastPInvCount as pi_nr_of_gi_since_last_cnt) as NrOfGoodsIssSinceLastPInvCount,
      sep.CurrentDate
}