@ObjectModel.usageType.sizeCategory: #XXL
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.dataClass:#TRANSACTIONAL
@VDM.private: true
@VDM.viewType: #COMPOSITE
@AccessControl.authorizationCheck:#NOT_REQUIRED
//@EndUserText.label: 'Consumption Delta'
define view entity P_SlowMoMatPredCnsmpnDelta as select from P_SlowMoMatPredCnsmpnFloat as rec
left outer join I_Product as prod
on prod.Product = rec.Material
{
key rec.InventoryConsumptionGroup,
key rec.CalendarMonth,
key rec.Material as Material,
key rec.Plant as Plant,
key rec.StockIdentifyingBatch,
key rec.SpecialStockIdfgSupplier,
key rec.SpecialStockIdfgSalesOrder,
key rec.SpecialStockIdfgSalesOrderItem,
key rec.SpecialStockIdfgWBSElement,
key rec.SpecialStockIdfgCustomer,
key rec.SpecialStockIdfgStockOwner,
key rec.InventorySpecialStockType,
key rec.InventoryStockType,
key rec.MaterialBaseUnit,
prod.ProductGroup as ProductGroup,
prod.ProductType as ProductType,
//Consumption per Month
rec.ConsumptionQtyM1,
rec.ConsumptionQtyM2,
rec.ConsumptionQtyM3,
rec.ConsumptionQtyM4,
rec.ConsumptionQtyM5,
rec.ConsumptionQtyM6,
rec.ConsumptionQtyM7,
rec.ConsumptionQtyM7 as target,
//Consumption Delta from Month to previous Month
cast(rec.ConsumptionQtyM2 - rec.ConsumptionQtyM1 as nsdm_consumption_quantity preserving type) as ConsumptionDeltaM2M1,
cast(rec.ConsumptionQtyM3 - rec.ConsumptionQtyM2 as nsdm_consumption_quantity preserving type) as ConsumptionDeltaM3M2,
cast(rec.ConsumptionQtyM4 - rec.ConsumptionQtyM3 as nsdm_consumption_quantity preserving type) as ConsumptionDeltaM4M3,
cast(rec.ConsumptionQtyM5 - rec.ConsumptionQtyM4 as nsdm_consumption_quantity preserving type) as ConsumptionDeltaM5M4,
cast(rec.ConsumptionQtyM6 - rec.ConsumptionQtyM5 as nsdm_consumption_quantity preserving type) as ConsumptionDeltaM6M5,
//Ratio Consumption Delta Month to previous Month devided by Consumption of Pervious Month
case when rec.ConsumptionDeltaFloatM2M1 = 0 then 0 else case when rec.ConsumptionQtyFloatM1 = 0
then 0 else rec.ConsumptionDeltaFloatM2M1 / rec.ConsumptionQtyFloatM1 end end as ConsumptionRatioM2M1,
case when rec.ConsumptionDeltaFloatM3M2 = 0 then 0 else case when rec.ConsumptionQtyFloatM2 = 0
then 0 else rec.ConsumptionDeltaFloatM3M2 / rec.ConsumptionQtyFloatM2 end end as ConsumptionRatioM3M2,
case when rec.ConsumptionDeltaFloatM4M3 = 0 then 0 else case when rec.ConsumptionQtyFloatM3 = 0
then 0 else rec.ConsumptionDeltaFloatM4M3 / rec.ConsumptionQtyFloatM3 end end as ConsumptionRatioM4M3,
case when rec.ConsumptionDeltaFloatM5M4 = 0 then 0 else case when rec.ConsumptionQtyFloatM4 = 0
then 0 else rec.ConsumptionDeltaFloatM5M4 / rec.ConsumptionQtyFloatM4 end end as ConsumptionRatioM5M4,
case when rec.ConsumptionDeltaFloatM6M5 = 0 then 0 else case when rec.ConsumptionQtyFloatM5 = 0
then 0 else rec.ConsumptionDeltaFloatM6M5 / rec.ConsumptionQtyFloatM5 end end as ConsumptionRatioM6M5,
//Number of BOMs used in per Month
rec.NumberOfBomM5,
rec.NumberOfBomM6,
rec.NumberOfBomM7,
rec.NumberOfBomM8,
rec.NumberOfBomM9,
rec.NumberOfBomM10,
//Number of BOMs Delta from Month to previous Month
cast(rec.NumberOfBomM6 - rec.NumberOfBomM5 as nsdm_number_of_bom_used_in preserving type) as NumberOfBomDeltaM6M5,
cast(rec.NumberOfBomM7 - rec.NumberOfBomM6 as nsdm_number_of_bom_used_in preserving type) as NumberOfBomDeltaM7M6,
cast(rec.NumberOfBomM8 - rec.NumberOfBomM7 as nsdm_number_of_bom_used_in preserving type) as NumberOfBomDeltaM8M7,
cast(rec.NumberOfBomM9 - rec.NumberOfBomM8 as nsdm_number_of_bom_used_in preserving type) as NumberOfBomDeltaM9M8,
cast(rec.NumberOfBomM10 - rec.NumberOfBomM9 as nsdm_number_of_bom_used_in preserving type) as NumberOfBomDeltaM10M9,
//Ratio Number of BOMs Delta Month to previous Month devided by Number of BOMs of Pervious Month
case when rec.NumberOfBomDeltaFloatM6M5 = 0 then 0 else case when rec.NumberOfBomFloatM5 = 0
then 0 else rec.NumberOfBomDeltaFloatM6M5 / rec.NumberOfBomFloatM5 end end as BomRatioM6M5,
case when rec.NumberOfBomDeltaFloatM7M6 = 0 then 0 else case when rec.NumberOfBomFloatM6 = 0
then 0 else rec.NumberOfBomDeltaFloatM7M6 / rec.NumberOfBomFloatM6 end end as BomRatioM7M6,
case when rec.NumberOfBomDeltaFloatM8M7 = 0 then 0 else case when rec.NumberOfBomFloatM7 = 0
then 0 else rec.NumberOfBomDeltaFloatM8M7 / rec.NumberOfBomFloatM7 end end as BomRatioM8M7,
case when rec.NumberOfBomDeltaFloatM9M8 = 0 then 0 else case when rec.NumberOfBomFloatM8 = 0
then 0 else rec.NumberOfBomDeltaFloatM9M8 / rec.NumberOfBomFloatM8 end end as BomRatioM9M8,
case when rec.NumberOfBomDeltaFloatM10M9 = 0 then 0 else case when rec.NumberOfBomFloatM9 = 0
then 0 else rec.NumberOfBomDeltaFloatM10M9 / rec.NumberOfBomFloatM9 end end as BomRatioM10M9,
// Consumption Intervall as number of consecutive previous Month withour Consumption
0 as ConsumptionIntervalM1,
case when rec.ConsumptionQtyM1 > 0 then 0 else 1 end as ConsumptionIntervalM2,
case when rec.ConsumptionQtyM2 > 0 then 0 else case when rec.ConsumptionQtyM1 > 0 then 1 else 2 end end as ConsumptionIntervalM3,
case when rec.ConsumptionQtyM3 > 0 then 0 else case when rec.ConsumptionQtyM2 > 0 then 1
else case when rec.ConsumptionQtyM1 > 0 then 2 else 3 end end end as ConsumptionIntervalM4,
case when rec.ConsumptionQtyM4 > 0 then 0 else case when rec.ConsumptionQtyM3 > 0 then 1
else case when rec.ConsumptionQtyM2 > 0 then 2
else case when rec.ConsumptionQtyM1 > 0 then 3 else 4 end end end end as ConsumptionIntervalM5,
case when rec.ConsumptionQtyM5 > 0 then 0 else case when rec.ConsumptionQtyM4 > 0 then 1
else case when rec.ConsumptionQtyM3 > 0 then 2
else case when rec.ConsumptionQtyM2 > 0 then 3
else case when rec.ConsumptionQtyM1 > 0 then 4 else 5 end end end end end as ConsumptionIntervalM6
}