@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