C_PhysInvtryProposal

DDL: C_PHYSINVTRYPROPOSAL Type: view_entity CONSUMPTION Package: ODATA_MM_IM_PI_MASS_CREATE

Proposals for new PI counts

C_PhysInvtryProposal is a Consumption CDS View that provides data about "Proposals for new PI counts" in SAP S/4HANA. It reads from 2 data sources (I_Plant, P_EnhPhysInvtryActvStkSepVal) and exposes 64 fields with key fields Plant, StorageLocation, Material, Batch, ValuationType. It has 22 associations to related views. Part of development package ODATA_MM_IM_PI_MASS_CREATE.

Data Sources (2)

SourceAliasJoin Type
I_Plant I_Plant inner
P_EnhPhysInvtryActvStkSepVal sep from

Associations (22)

CardinalityTargetAliasCondition
[0..1] I_Plant _Plant $projection.Plant = _Plant.Plant
[0..1] I_StorageLocation _StorageLocation $projection.Plant = _StorageLocation.Plant and $projection.StorageLocation = _StorageLocation.StorageLocation
[0..1] I_Material _Material $projection.Material = _Material.Material
[0..1] I_Product _Product $projection.Material = _Product.Product
[0..1] I_Producttype _ProductType $projection.ProductType = _ProductType.ProductType
[0..1] I_ProductGroup _ProductGroup $projection.ProductGroup = _ProductGroup.MaterialGroup
[0..1] I_ProductStorageLocation _ProductStorageLocation $projection.Material = _ProductStorageLocation.Product and $projection.Plant = _ProductStorageLocation.Plant and $projection.StorageLocation = _ProductStorageLocation.StorageLocation
[0..1] I_Supplier _Supplier $projection.Supplier = _Supplier.Supplier
[1..1] I_SupplierCompanyByPlant _SupplierCompanyByPlant $projection.Supplier = _SupplierCompanyByPlant.Supplier and $projection.Plant = _SupplierCompanyByPlant.Plant
[0..1] I_Customer _Customer $projection.Customer = _Customer.Customer
[1..1] I_CustomerCompanyByPlant _CustomerCompanyByPlant $projection.Customer = _CustomerCompanyByPlant.Customer and $projection.Plant = _CustomerCompanyByPlant.Plant
[0..1] I_InventoryStockType _InventoryStockType $projection.InventoryStockType = _InventoryStockType.InventoryStockType
[0..1] I_PhysInvtrySpecialStockTypeVH _PhysInvtrySpecialStockTypeVH $projection.InventorySpecialStockType = _PhysInvtrySpecialStockTypeVH.InventorySpecialStockType
[0..1] I_SalesOrder _SalesOrder $projection.SalesOrder = _SalesOrder.SalesOrder
[0..1] I_UnitOfMeasure _MaterialBaseUnit $projection.MaterialBaseUnit = _MaterialBaseUnit.UnitOfMeasure
[0..1] I_Currency _Currency $projection.CompanyCodeCurrency = _Currency.Currency
[0..1] I_WBSElementByInternalKey _WBSElement $projection.WBSElementInternalID = _WBSElement.WBSElementInternalID
[0..1] I_CurrentMatlValnPrice _Price _Price.Material = $projection.Material and I_Plant.ValuationArea = _Price.ValuationArea and sep.InventoryValuationType = _Price.InventoryValuationType and sep.InventorySpecialStockTypeVal = _Price.InvtryValnSpecialStockType and sep.SalesOrderVal = _Price.SalesOrder and sep.SalesOrderItemVal = _Price.SalesOrderItem and sep.WBSElementInternalIDVal = _Price.WBSElementInternalID and sep.Supplier = '' and _Price.CurrencyRole = '10' and -- _Price.PeriodType = 'LF' and ( sep.InventorySpecialStockType = '' or sep.InventorySpecialStockType = 'V' or sep.InventorySpecialStockType = 'W' or sep.InventorySpecialStockType = 'O' or sep.InventorySpecialStockValnType <> '' ) and _Price.LedgerValnCrcyRoleIsUsedInLogs = 'X'
[0..1] I_CycleCountingSettings _CycleCounting _CycleCounting.CycleCountType = $projection.CycleCountType and _CycleCounting.Plant = $projection.Plant
[1..1] I_Product _ProductExt $projection.Material = _ProductExt.Product
[1..1] I_ProductPlant _ProductPlant $projection.Material = _ProductPlant.Product and $projection.Plant = _ProductPlant.Plant
[1..1] I_Batch _Batch $projection.Material = _Batch.Material and $projection.Plant = _Batch.Plant and $projection.Batch = _Batch.Batch

Annotations (11)

NameValueLevelField
EndUserText.label Proposals for new PI counts view
AccessControl.authorizationCheck #CHECK view
ObjectModel.usageType.sizeCategory #XL view
ObjectModel.usageType.serviceQuality #D view
ObjectModel.usageType.dataClass #TRANSACTIONAL view
ObjectModel.createEnabled false view
ObjectModel.updateEnabled false view
ObjectModel.deleteEnabled false view
VDM.private false view
VDM.viewType #CONSUMPTION view
Search.searchable true view

Fields (64)

KeyFieldSource TableSource FieldDescription
KEY Plant P_EnhPhysInvtryActvStkSepVal Plant
KEY StorageLocation P_EnhPhysInvtryActvStkSepVal StorageLocation
KEY Material P_EnhPhysInvtryActvStkSepVal Material
KEY Batch P_EnhPhysInvtryActvStkSepVal RealProductBatch
KEY ValuationType
KEY Supplier P_EnhPhysInvtryActvStkSepVal Supplier
KEY SalesOrder P_EnhPhysInvtryActvStkSepVal SalesOrder
KEY SalesOrderItem P_EnhPhysInvtryActvStkSepVal SalesOrderItem
KEY WBSElement P_EnhPhysInvtryActvStkSepVal WBSElement
KEY Customer P_EnhPhysInvtryActvStkSepVal Customer
KEY StockOwner P_EnhPhysInvtryActvStkSepVal StockOwner
KEY InventoryStockType P_EnhPhysInvtryActvStkSepVal InventoryStockType
KEY InventorySpecialStockType P_EnhPhysInvtryActvStkSepVal InventorySpecialStockType
KEY MaterialIsPostedToStock P_EnhPhysInvtryActvStkSepVal MaterialIsPostedToStock
SearchForBatch P_EnhPhysInvtryActvStkSepVal Batch
SearchForValuationType P_EnhPhysInvtryActvStkSepVal SearchForValuationType
MaterialBaseUnit P_EnhPhysInvtryActvStkSepVal MaterialBaseUnit
CycleCountType P_EnhPhysInvtryActvStkSepVal CycleCountType
NmbrOfPhysInvtryPerFiscalYear P_EnhPhysInvtryActvStkSepVal NmbrOfPhysInvtryPerFiscalYear
PhysInvtryIntvlForCycCounting P_EnhPhysInvtryActvStkSepVal PhysInvtryIntvlForCycCounting
PhysInvtryFloatTimeCycCounting P_EnhPhysInvtryActvStkSepVal PhysInvtryFloatTimeCycCounting
WBSElementInternalID P_EnhPhysInvtryActvStkSepVal WBSElementInternalID
WBSDescription _WBSElement WBSDescription
ProductType P_EnhPhysInvtryActvStkSepVal ProductType Material Type
ProductGroup P_EnhPhysInvtryActvStkSepVal ProductGroup Material Group
SerialIdentifierAssgmtProfile _ProductPlant SerialNumberProfile
WarehouseStorageBin _ProductStorageLocation WarehouseStorageBin
IsMarkedForDeletion _Product IsMarkedForDeletion
MatlWrhsStkQtyInMatlBaseUnit
InventoryPrice
MaterialPriceUnitQty _Price MaterialPriceUnitQty
CompanyCodeCurrency P_EnhPhysInvtryActvStkSepVal CompanyCodeCurrency
NumberOfPhysInventoryCounts P_EnhPhysInvtryActvStkSepVal NumberOfPhysInventoryCounts
NumberOfPInvAdjustmentsPerYear P_EnhPhysInvtryActvStkSepVal NumberOfPInvAdjustmentsPerYear
PInvDiffQtyPerYearInBaseUnit P_EnhPhysInvtryActvStkSepVal PInvDiffQtyPerYearInBaseUnit
PhysicalInventoryLastCountDate P_EnhPhysInvtryActvStkSepVal PhysicalInventoryLastCountDate
NmbrOfDaysSinceLastPInvCount P_EnhPhysInvtryActvStkSepVal NmbrOfDaysSinceLastPInvCount
PhysicalInventoryItemIsCounted P_EnhPhysInvtryActvStkSepVal PhysicalInventoryItemIsCounted
NrOfGdsRcptSinceLastPInvCount P_EnhPhysInvtryActvStkSepVal NrOfGdsRcptSinceLastPInvCount
GdsRcptQtySinceLastCtInBsUnt P_EnhPhysInvtryActvStkSepVal GdsRcptQtySinceLastCtInBsUnt Received Quantity Since Last Count
AvgStkQtySinceLastCountInBsUnt
NrOfGoodsIssSinceLastPInvCount P_EnhPhysInvtryActvStkSepVal NrOfGoodsIssSinceLastPInvCount
GdsIssQtySinceLastCountInBsUnt P_EnhPhysInvtryActvStkSepVal GdsIssQtySinceLastCountInBsUnt Issued Quantity Since Last Count
UnitOfMeasure
_Plant _Plant
_StorageLocation _StorageLocation
_Supplier _Supplier
_Material _Material
_SupplierCompanyByPlant _SupplierCompanyByPlant
_Customer _Customer
_CustomerCompanyByPlant _CustomerCompanyByPlant
_PhysInvtrySpecialStockTypeVH _PhysInvtrySpecialStockTypeVH
_SalesOrder _SalesOrder
_MaterialBaseUnit _MaterialBaseUnit
_Currency _Currency
_WBSElement _WBSElement
_Product _Product
_ProductType _ProductType
_ProductGroup _ProductGroup
_InventoryStockType _InventoryStockType
_CycleCounting _CycleCounting
_ProductExt _ProductExt
_ProductPlant _ProductPlant
_Batch _Batch
@EndUserText.label: 'Proposals for new PI counts'

@AccessControl.authorizationCheck: #CHECK
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.dataClass: #TRANSACTIONAL
@ObjectModel.createEnabled: false
@ObjectModel.updateEnabled: false
@ObjectModel.deleteEnabled: false


@VDM.private: false
@VDM.viewType: #CONSUMPTION
@Search.searchable: true

@ObjectModel: {
    semanticKey: ['Material', 'Plant', 'StorageLocation']
}

define view entity C_PhysInvtryProposal
  as select from P_EnhPhysInvtryActvStkSepVal as sep

    inner join   I_Plant on sep.Plant = I_Plant.Plant

  association [0..1] to I_Plant                        as _Plant                        on  $projection.Plant = _Plant.Plant

  association [0..1] to I_StorageLocation          as _StorageLocation              on  $projection.Plant           = _StorageLocation.Plant
                                                                                        and $projection.StorageLocation = _StorageLocation.StorageLocation

  association [0..1] to I_Material                     as _Material                     on  $projection.Material = _Material.Material

  association [0..1] to I_Product                      as _Product                      on  $projection.Material = _Product.Product

  association [0..1] to I_Producttype                  as _ProductType                  on  $projection.ProductType = _ProductType.ProductType

  association [0..1] to I_ProductGroup                 as _ProductGroup                 on  $projection.ProductGroup = _ProductGroup.MaterialGroup

  association [0..1] to I_ProductStorageLocation       as _ProductStorageLocation       on  $projection.Material        = _ProductStorageLocation.Product
                                                                                        and $projection.Plant           = _ProductStorageLocation.Plant
                                                                                        and $projection.StorageLocation = _ProductStorageLocation.StorageLocation

  association [0..1] to I_Supplier                     as _Supplier                     on  $projection.Supplier = _Supplier.Supplier

  association [1..1] to I_SupplierCompanyByPlant       as _SupplierCompanyByPlant       on  $projection.Supplier = _SupplierCompanyByPlant.Supplier
                                                                                        and $projection.Plant    = _SupplierCompanyByPlant.Plant

  association [0..1] to I_Customer                     as _Customer                     on  $projection.Customer = _Customer.Customer

  association [1..1] to I_CustomerCompanyByPlant       as _CustomerCompanyByPlant       on  $projection.Customer = _CustomerCompanyByPlant.Customer
                                                                                        and $projection.Plant    = _CustomerCompanyByPlant.Plant

  association [0..1] to I_InventoryStockType           as _InventoryStockType           on  $projection.InventoryStockType = _InventoryStockType.InventoryStockType

  association [0..1] to I_PhysInvtrySpecialStockTypeVH as _PhysInvtrySpecialStockTypeVH on  $projection.InventorySpecialStockType = _PhysInvtrySpecialStockTypeVH.InventorySpecialStockType

  association [0..1] to I_SalesOrder                   as _SalesOrder                   on  $projection.SalesOrder = _SalesOrder.SalesOrder

  association [0..1] to I_UnitOfMeasure                as _MaterialBaseUnit             on  $projection.MaterialBaseUnit = _MaterialBaseUnit.UnitOfMeasure

  association [0..1] to I_Currency                     as _Currency                     on  $projection.CompanyCodeCurrency = _Currency.Currency

  association [0..1] to I_WBSElementByInternalKey      as _WBSElement                   on  $projection.WBSElementInternalID = _WBSElement.WBSElementInternalID

  association [0..1] to I_CurrentMatlValnPrice         as _Price                        on  _Price.Material                       = $projection.Material
                                                                                        and I_Plant.ValuationArea                 =  _Price.ValuationArea
                                                                                        and sep.InventoryValuationType            =  _Price.InventoryValuationType
                                                                                        and sep.InventorySpecialStockTypeVal      =  _Price.InvtryValnSpecialStockType
                                                                                        and sep.SalesOrderVal                     =  _Price.SalesOrder
                                                                                        and sep.SalesOrderItemVal                 =  _Price.SalesOrderItem
                                                                                        and sep.WBSElementInternalIDVal           =  _Price.WBSElementInternalID
                                                                                        and sep.Supplier                          =  ''
                                                                                        and //if consider xobew, sep.SupplierVal = _Price.Supplier

                                                                                            _Price.CurrencyRole                   =  '10'
                                                                                        and //Company Code Currency

                                                                                            -- _Price.PeriodType = 'LF'   and    //Current Period

                                                                                            (
    sep.InventorySpecialStockType                                                                                                 =  ''
    or sep.InventorySpecialStockType                                                                                              =  'V'
    or sep.InventorySpecialStockType                                                                                              =  'W'
    or sep.InventorySpecialStockType                                                                                              =  'O'
    or //if consider xobew, sep.InventorySpecialStockTypeVal = 'O'

    sep.InventorySpecialStockValnType                                                                                             <> ''
  )
                                                                                        and _Price.LedgerValnCrcyRoleIsUsedInLogs =  'X'


  association [0..1] to I_CycleCountingSettings        as _CycleCounting                on  _CycleCounting.CycleCountType = $projection.CycleCountType
                                                                                        and _CycleCounting.Plant          = $projection.Plant

  // Datasource extensibility

  association [1..1] to I_Product                      as _ProductExt                   on  $projection.Material = _ProductExt.Product
  association [1..1] to I_ProductPlant                 as _ProductPlant                 on  $projection.Material = _ProductPlant.Product
                                                                                        and $projection.Plant    = _ProductPlant.Plant
  association [1..1] to I_Batch                        as _Batch                        on  $projection.Material = _Batch.Material
                                                                                        and $projection.Plant    = _Batch.Plant
                                                                                        and $projection.Batch    = _Batch.Batch


{

      @UI: { selectionField: [ { position: 10 }],
             lineItem:       [       { position: 20,
                               importance: #HIGH }],
             fieldGroup:     [     { qualifier: 'Header', position: 20 }] }
      @ObjectModel: { foreignKey: { association: '_Plant' } }
      @Consumption: { semanticObject: 'Plant'
//                      valueHelp: '_Plant' 

                      }
      @Consumption.valueHelpDefinition: [ { entity: { name: 'I_Plant',          element: 'Plant' }, label: 'Possible Entries for Plants' },
                                          { entity: { name: 'I_MatlDocPlantVH', element: 'Plant' }, qualifier: 'Stock Postings Value Help' },
                                          { entity: { name: 'I_PlantAddressVH', element: 'Plant' }, qualifier: 'Address Value Help' }, 
                                          { entity: { name: 'I_PlantStdVH',     element: 'Plant' }, qualifier: 'Name Value Help' } ]                
      @Search.defaultSearchElement: true
  key sep.Plant,

      @UI: { selectionField: [ { position: 20 }],
             lineItem:       [       { position: 30,
                               importance: #HIGH }],
             fieldGroup:     [     { qualifier: 'Header', position: 30}] }
      @ObjectModel: { foreignKey: { association: '_StorageLocation' },
                      enabled: #('EXTERNAL_CALCULATION') }
      @Consumption: { semanticObject: 'StorageLocation',
//                    valueHelp: '_StorageLocation'

                      valueHelpDefinition: [
                              { entity:  { name:    'I_StorageLocationStdVH',
                                          element: 'StorageLocation' }
                             }] 
                      }
      @Search.defaultSearchElement: true
  key sep.StorageLocation,

      @UI: { lineItem: [ { position: 10,
                         importance: #HIGH }],
             textArrangement: #TEXT_FIRST }
      @ObjectModel: { foreignKey: { association: '_Product' } }
      @Consumption: { semanticObject: 'Material',
                      valueHelpDefinition: [
                              { entity:  { name:    'I_ProductVH',
                                           element: 'Product' }
                              }] }
      @Search.defaultSearchElement: true
  key sep.Material,

      @ObjectModel: { enabled: #('EXTERNAL_CALCULATION'),
                      filter: { transformedBy: 'CL_MM_IM_PHYS_INV_FILTER_EXIT' }
                     } 

      @Consumption: { semanticObject: 'Batch',
                  valueHelpDefinition: [   { entity:  { name:    'I_BatchWithValuationVH',
                                                        element: 'Batch' },
                                             additionalBinding: [  { localElement: 'Plant',                     element: 'Plant' },
                                                                   { localElement: 'Material',                  element: 'Material' }, 
                                                                   { localElement: 'ValuationType',             element: 'ValuationType' } ],
                                             label: 'Batch (General)',
                                             qualifier: 'Secondary Value Help' },
                                           { entity:  { name:    'I_PhysInvtryBatchVH',
                                                        element: 'Batch' },
                                             additionalBinding: [  { localElement: 'Plant',            element: 'Plant' },
                                                                   { localElement: 'StorageLocation',  element: 'StorageLocation' },
                                                                   { localElement: 'Material',         element: 'Material' },
                                                                   { localElement: 'ValuationType',    element: 'InventoryValuationType' }  ],           
                                             label: 'Batch by Plant and Material' }             
                                       ] }                    

  key sep.RealProductBatch as Batch,
  
      @ObjectModel: { enabled: #('EXTERNAL_CALCULATION'),
                      filter: { transformedBy: 'CL_MM_IM_PHYS_INV_FILTER_EXIT' }
                    } 
                    
      @Consumption: { valueHelpDefinition: [   { entity:  { name:    'I_PhysInvtryMatValnTypeVH',
                                                        element: 'InventoryValuationType' },
                                             additionalBinding: [  { localElement: 'Plant',                     element: 'Plant' },
                                                                   { localElement: 'Material',                  element: 'Material' } ],
                                             label: 'Valuation Type' }                                                   
                                       ] }        
                       
  key cast(sep.InventoryValuationType as bwtar_d) as ValuationType,   

      @ObjectModel: { foreignKey.association: '_Supplier',
                      enabled:  #('EXTERNAL_CALCULATION'),
                      filter: { transformedBy: 'CL_MM_IM_PHYS_INV_FILTER_EXIT' }
                     }
      @Consumption: { semanticObject: 'Supplier',
                      valueHelpDefinition: [
                            { entity:  { name:    'I_Supplier_VH',
                                         element: 'Supplier' }
                            }] }
      @Search.defaultSearchElement: true 
  key sep.Supplier,

      @ObjectModel: { foreignKey: { association: '_SalesOrder' },
                      enabled: #('EXTERNAL_CALCULATION'),
                      filter: { transformedBy: 'CL_MM_IM_PHYS_INV_FILTER_EXIT' }
                       }
      @Consumption: { semanticObject: 'SalesOrder',
                      valueHelpDefinition: [
                          { entity:  { name:    'I_SalesOrderStdVH',
                                       element: 'SalesOrder' }
                          }] }
      @Search.defaultSearchElement: true
  key sep.SalesOrder,

      @ObjectModel: { enabled: #('EXTERNAL_CALCULATION'),
                      filter: { transformedBy: 'CL_MM_IM_PHYS_INV_FILTER_EXIT' }
                     } 
  key sep.SalesOrderItem,

      @ObjectModel: { enabled: #('EXTERNAL_CALCULATION'),
                      filter: { transformedBy: 'CL_MM_IM_PHYS_INV_FILTER_EXIT' }
                     } 
      @Consumption: { valueHelpDefinition: [
                            { entity:  { name:    'I_WBSElementStdVH',
                                         element: 'WBSElement' }
                            }] }
      @ObjectModel.text.element:  [ 'WBSDescription' ]
  key sep.WBSElement,

      @Consumption: { semanticObject: 'Customer',
                      valueHelpDefinition: [
                            { entity:  { name:    'I_Customer_VH',
                                         element: 'Customer' }
                            }] }
      @ObjectModel: { enabled: #('EXTERNAL_CALCULATION'),
                      filter: { transformedBy: 'CL_MM_IM_PHYS_INV_FILTER_EXIT' } 
                     } 
      @Search.defaultSearchElement: true
  key sep.Customer,

      @Consumption: { semanticObject: 'Customer',
                      valueHelpDefinition: [
                            { entity:  { name:    'I_Customer_VH',
                                         element: 'Customer' }
                            }] }
      @ObjectModel: { enabled: #('EXTERNAL_CALCULATION'),
                      filter: { transformedBy: 'CL_MM_IM_PHYS_INV_FILTER_EXIT' }
                     } 
      @Search.defaultSearchElement: true
  key sep.StockOwner,

      @UI.textArrangement: #TEXT_ONLY
      @UI: { fieldGroup:     [     { qualifier: 'Header', position: 40 }] }
      @Consumption.valueHelpDefinition: [
                            { entity:  { name:    'I_InventoryStockType',
                                         element: 'InventoryStockType' }
                            }]
  key sep.InventoryStockType,

      @UI: { fieldGroup:     [     { qualifier: 'Header', position: 50 }],
             textArrangement: #TEXT_FIRST }
      @ObjectModel: { enabled: #('EXTERNAL_CALCULATION'),
                      filter: { transformedBy: 'CL_MM_IM_PHYS_INV_FILTER_EXIT' } }
      @Consumption.valueHelpDefinition: [
                            { entity:  { name:    'I_PhysInvtrySpecialStockTypeVH',
                                         element: 'InventorySpecialStockType' }
                            }]
  key sep.InventorySpecialStockType,

      @Consumption: {valueHelpDefinition: [  { entity:  { name: 'I_MaterialIsPostedToStock', element : 'MaterialIsPostedToStock' } }] }
      @Consumption.filter: { selectionType     : #SINGLE,
                             multipleSelections: false,
                             mandatory         : true,
                             defaultValue      : 'X'  }
      @Environment.sql.passValue: true
      @Semantics.booleanIndicator: true
      @UI.dataPoint.title: 'Posted to Stock'
  key sep.MaterialIsPostedToStock, 
     
// The field SearchForBatch is added to support the Fuzzy Search. The origin field Batch is

// cleared for non batch managed materials which are split valuated. The case statement to clear the batch

// is implemented in view P_EnhPhysInvtryActvStkSepVal using the field RealProductBatch.   

// Using a case statement or instead an union to replace the case then is not possible to realize the

// Fuzzy Search because of dumpts that the feature is not supported by the database.

      @Search: { defaultSearchElement: true, 
                 fuzzinessThreshold: 0.8 }
      @UI.hidden: true
      sep.Batch as SearchForBatch,
      @Search: { defaultSearchElement: true, 
                 fuzzinessThreshold: 0.8 }
      @UI.hidden: true
      sep.SearchForValuationType,

      @Consumption.valueHelpDefinition: [
                            { entity:  { name:    'I_UnitOfMeasureStdVH',
                                         element: 'UnitOfMeasure' }
                            } ]
      sep.MaterialBaseUnit, //2928780


      @Consumption: { valueHelpDefinition: [
                            { entity:  { name:    'I_CycleCountingSettings',
                                         element: 'CycleCountType' },
                              additionalBinding: [
                                       { localElement: 'Plant',
                                         element: 'Plant' } ]
                            }
                       ] }
      @UI: { fieldGroup: [ { qualifier: 'CycleCountingFacet',
                    position: 10,
                    importance: #HIGH }] }
      @ObjectModel: { foreignKey: { association: '_CycleCounting' },
                      enabled: #('EXTERNAL_CALCULATION') } // creates a Field Control Propertie in SEGW

      sep.CycleCountType,

      @UI: { fieldGroup: [ { qualifier: 'CycleCountingFacet',
                    position: 20,
                    importance: #HIGH }] }
      @Consumption.filter.hidden
      @ObjectModel: { enabled: #('EXTERNAL_CALCULATION') } // creates a Field Control Propertie in SEGW

      sep.NmbrOfPhysInvtryPerFiscalYear,

      @UI: { fieldGroup: [ { qualifier: 'CycleCountingFacet',
                    position: 30,
                    importance: #HIGH }] }
      @Consumption.filter.hidden
      @ObjectModel: { enabled: #('EXTERNAL_CALCULATION') } // creates a Field Control Propertie in SEGW

      //@Semantics.quantity.unitOfMeasure: 'UnitOfMeasure'

      sep.PhysInvtryIntvlForCycCounting,

      @UI: { fieldGroup: [ { qualifier: 'CycleCountingFacet',
                    position: 40,
                    importance: #HIGH }] }
      @Consumption.filter.hidden
      @ObjectModel: { enabled: #('EXTERNAL_CALCULATION') } // creates a Field Control Propertie in SEGW

      //@Semantics.quantity.unitOfMeasure: 'UnitOfMeasure'

      sep.PhysInvtryFloatTimeCycCounting,


      @UI.hidden: true
      sep.WBSElementInternalID,

      @UI.hidden: true
      @Semantics: { text: true }
      _WBSElement.WBSDescription,
      //===============================================================================================

      // Fields from product master data

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

      @EndUserText.label: 'Material Type'
      @Consumption.valueHelpDefinition: [{ entity.name: 'I_ProductType',
                                           entity.element: 'ProductType' }]
      @UI.textArrangement: #TEXT_ONLY
      sep.ProductType,

      @EndUserText.label: 'Material Group'
      @Consumption.valueHelpDefinition: [{ entity.name: 'I_ProductGroup',
                                           entity.element: 'MaterialGroup' }]
      @UI.textArrangement: #TEXT_ONLY
      sep.ProductGroup,

      @UI.textArrangement: #TEXT_ONLY
      @ObjectModel.enabled: #('EXTERNAL_CALCULATION')
      _ProductPlant.SerialNumberProfile                                                                             as SerialIdentifierAssgmtProfile, //2974210


      @ObjectModel.enabled: #('EXTERNAL_CALCULATION')
      _ProductStorageLocation.WarehouseStorageBin,

      @ObjectModel.enabled: #('EXTERNAL_CALCULATION')
      @Consumption.filter.selectionType: #SINGLE
      _Product.IsMarkedForDeletion,

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

      // Quantities

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

      @Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
      @UI.fieldGroup: [ { qualifier: 'Book',
                        position: 30,
                        importance: #HIGH }]
      cast(sep.MatlWrhsStkQtyInMatlBaseUnit as pi_current_quantity)                                                     as MatlWrhsStkQtyInMatlBaseUnit,

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

      // Prices

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

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      @ObjectModel.enabled: #('EXTERNAL_CALCULATION')
      cast(cast(_Price.InventoryPrice as abap.curr( 11, 2 )) as pi_inventory_price preserving type)                 as InventoryPrice,  //down cast first and then cast on data element

      @Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
      @ObjectModel.enabled: #('EXTERNAL_CALCULATION')
      _Price.MaterialPriceUnitQty,

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

      // Fields from plant/company master data

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

      @Consumption.valueHelpDefinition: [
                              { entity:  { name:    'I_Currency',
                                           element: 'Currency' }
                              }]
      sep.CompanyCodeCurrency,

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

      // Key Figures from PI (only looking at current fiscal year)

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

      sep.NumberOfPhysInventoryCounts,

      @UI: { fieldGroup: [ { qualifier: 'Adjustments',
                           position: 10 }] }
      sep.NumberOfPInvAdjustmentsPerYear,
      @Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
      @UI: { fieldGroup: [ { qualifier: 'Adjustments',
                           position: 20 }] }
      sep.PInvDiffQtyPerYearInBaseUnit,

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

      // Key Figures from PI (looking at complete history, not only at current fiscal year)

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

      @ObjectModel.enabled: #('EXTERNAL_CALCULATION')
      sep.PhysicalInventoryLastCountDate,

      @UI.dataPoint.title: 'Days Since Last Count'
      @Consumption.filter.hidden
      sep.NmbrOfDaysSinceLastPInvCount,

      sep.PhysicalInventoryItemIsCounted,

      @UI: { fieldGroup: [ { qualifier: 'GoodsReceipts',
                           position: 10 }] }
      @ObjectModel.enabled: #('EXTERNAL_CALCULATION')
      sep.NrOfGdsRcptSinceLastPInvCount,
      @Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
      @UI: { fieldGroup: [ { qualifier: 'GoodsReceipts',
                           position: 20 }] }
      @EndUserText.label: 'Received Quantity Since Last Count'
      @ObjectModel.enabled: #('EXTERNAL_CALCULATION')
      sep.GdsRcptQtySinceLastCtInBsUnt                                                                              as GdsRcptQtySinceLastCtInBsUnt,

      @Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
      @UI: { fieldGroup: [ { qualifier: 'Book',
                           position: 10 }] }
      @ObjectModel.enabled: #('EXTERNAL_CALCULATION')
      //  cast(round(MatlWrhsStkQtyInMatlBaseUnit - sep.AvgStkQtySinceLastCountCorrect, 3) as pi_average_book_quantity) as AvgStkQtySinceLastCountInBsUnt,

      cast(round(sep.MatlWrhsStkQtyInMatlBaseUnit - cast( sep.AvgStkQtySinceLastCountCorrect as nsdm_stock_qty ), 3) as pi_average_book_quantity) as AvgStkQtySinceLastCountInBsUnt,

      @UI: { fieldGroup: [ { qualifier: 'GoodsIssues',
                            position: 30 }] }
      @ObjectModel.enabled: #('EXTERNAL_CALCULATION')
      cast(
        case
          when sep.PhysicalInventoryLastCountDate is null 
            then 0
          when sep.GdsIssQtySinceLastCountInBsUnt = 0 or sep.GdsIssQtySinceLastCountInBsUnt is null 
            then 0
          when sep.MatlWrhsStkQtyInMatlBaseUnit < sep.AvgStkQtySinceLastCountCorrect 
            then 0
          when sep.MatlWrhsStkQtyInMatlBaseUnit = sep.AvgStkQtySinceLastCountCorrect 
            then dats_days_between(sep.PhysicalInventoryLastCountDate,sep.CurrentDate)
          else division( cast( sep.GdsIssQtySinceLastCountInBsUnt as abap.dec( 13, 3 ) ), 
                         cast( sep.MatlWrhsStkQtyInMatlBaseUnit as abap.dec( 31, 14 ) ) - sep.AvgStkQtySinceLastCountCorrect, 1 )
        end as pi_turnover_since_last_cnt)                                                                          as InvtryTurnoverSinceLastCnt,

      @UI: { fieldGroup: [ { qualifier: 'GoodsIssues',
                            position: 10 }] }
      @ObjectModel.enabled: #('EXTERNAL_CALCULATION')
      sep.NrOfGoodsIssSinceLastPInvCount,

      @Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
      @UI: { fieldGroup: [ { qualifier: 'GoodsIssues',
                            position: 20 }] }
      @EndUserText.label: 'Issued Quantity Since Last Count'
      @ObjectModel.enabled: #('EXTERNAL_CALCULATION')
      sep.GdsIssQtySinceLastCountInBsUnt                                                                            as GdsIssQtySinceLastCountInBsUnt,

      @UI.hidden: true
      cast( cast( '10' as char3) as msehi)                                                                          as UnitOfMeasure, //Days


      @Consumption.filter.hidden: true
      _Plant,

      @Consumption.filter.hidden: true
      _StorageLocation,

      @Consumption.filter.hidden: true
      _Supplier,

      @Consumption.filter.hidden: true
      _Material,

      @Consumption.filter.hidden: true
      _SupplierCompanyByPlant,

      @Consumption.filter.hidden: true
      _Customer,

      @Consumption.filter.hidden: true
      _CustomerCompanyByPlant,


      @Consumption.filter.hidden: true
      _PhysInvtrySpecialStockTypeVH,

      @Consumption.filter.hidden: true
      _SalesOrder,

      @Consumption.filter.hidden: true
      _MaterialBaseUnit,

      @Consumption.filter.hidden: true
      _Currency,

      @Consumption.filter.hidden: true
      _WBSElement,

      @Consumption.filter.hidden: true
      _Product,

      @Consumption.filter.hidden: true
      _ProductType,

      @Consumption.filter.hidden: true
      _ProductGroup,

      @Consumption.filter.hidden: true
      _InventoryStockType,

      @Consumption.filter.hidden: true
      _CycleCounting,

      // Datasource extensibility

      @Consumption.filter.hidden: true
      _ProductExt,
      @Consumption.filter.hidden: true
      _ProductPlant,
      @Consumption.filter.hidden: true
      _Batch

}

// v3405185

where
  sep.InventoryStockType = '02'
  or
  sep.InventoryStockType = '07'
  or
  (
    sep.InventoryStockType = '01' and _Batch.MatlBatchIsInRstrcdUseStock is null
    or
    sep.InventoryStockType = '01' and _Batch.MatlBatchIsInRstrcdUseStock = ' '
    or
    sep.InventoryStockType = '08' and _Batch.MatlBatchIsInRstrcdUseStock = 'X'
  )
// ^3405185