@AbapCatalog.sqlViewName: 'PSLOWMOMATCDELTA'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@ObjectModel.usageType.sizeCategory: #XXL
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.dataClass:#TRANSACTIONAL
@ClientHandling.algorithm: #SESSION_VARIABLE
@VDM.private: true
@VDM.viewType: #COMPOSITE
@AccessControl.authorizationCheck:#NOT_REQUIRED
//@EndUserText.label: 'Consumption Delta'
define view 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
ConsumptionQtyM1,
ConsumptionQtyM2,
ConsumptionQtyM3,
ConsumptionQtyM4,
ConsumptionQtyM5,
ConsumptionQtyM6,
ConsumptionQtyM7,
ConsumptionQtyM7 as target,
//Consumption Delta from Month to previous Month
cast(ConsumptionQtyM2 - ConsumptionQtyM1 as nsdm_consumption_quantity preserving type) as ConsumptionDeltaM2M1,
cast(ConsumptionQtyM3 - ConsumptionQtyM2 as nsdm_consumption_quantity preserving type) as ConsumptionDeltaM3M2,
cast(ConsumptionQtyM4 - ConsumptionQtyM3 as nsdm_consumption_quantity preserving type) as ConsumptionDeltaM4M3,
cast(ConsumptionQtyM5 - ConsumptionQtyM4 as nsdm_consumption_quantity preserving type) as ConsumptionDeltaM5M4,
cast(ConsumptionQtyM6 - ConsumptionQtyM5 as nsdm_consumption_quantity preserving type) as ConsumptionDeltaM6M5,
//Ratio Consumption Delta Month to previous Month devided by Consumption of Pervious Month
case when ConsumptionDeltaFloatM2M1 = 0 then 0 else case when ConsumptionQtyFloatM1 = 0
then 0 else ConsumptionDeltaFloatM2M1 / ConsumptionQtyFloatM1 end end as ConsumptionRatioM2M1,
case when ConsumptionDeltaFloatM3M2 = 0 then 0 else case when ConsumptionQtyFloatM2 = 0
then 0 else ConsumptionDeltaFloatM3M2 / ConsumptionQtyFloatM2 end end as ConsumptionRatioM3M2,
case when ConsumptionDeltaFloatM4M3 = 0 then 0 else case when ConsumptionQtyFloatM3 = 0
then 0 else ConsumptionDeltaFloatM4M3 / ConsumptionQtyFloatM3 end end as ConsumptionRatioM4M3,
case when ConsumptionDeltaFloatM5M4 = 0 then 0 else case when ConsumptionQtyFloatM4 = 0
then 0 else ConsumptionDeltaFloatM5M4 / ConsumptionQtyFloatM4 end end as ConsumptionRatioM5M4,
case when ConsumptionDeltaFloatM6M5 = 0 then 0 else case when ConsumptionQtyFloatM5 = 0
then 0 else ConsumptionDeltaFloatM6M5 / ConsumptionQtyFloatM5 end end as ConsumptionRatioM6M5,
//Number of BOMs used in per Month
NumberOfBomM5,
NumberOfBomM6,
NumberOfBomM7,
NumberOfBomM8,
NumberOfBomM9,
NumberOfBomM10,
//Number of BOMs Delta from Month to previous Month
cast(NumberOfBomM6 - NumberOfBomM5 as nsdm_number_of_bom_used_in preserving type) as NumberOfBomDeltaM6M5,
cast(NumberOfBomM7 - NumberOfBomM6 as nsdm_number_of_bom_used_in preserving type) as NumberOfBomDeltaM7M6,
cast(NumberOfBomM8 - NumberOfBomM7 as nsdm_number_of_bom_used_in preserving type) as NumberOfBomDeltaM8M7,
cast(NumberOfBomM9 - NumberOfBomM8 as nsdm_number_of_bom_used_in preserving type) as NumberOfBomDeltaM9M8,
cast(NumberOfBomM10 - 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 NumberOfBomDeltaFloatM6M5 = 0 then 0 else case when NumberOfBomFloatM5 = 0
then 0 else NumberOfBomDeltaFloatM6M5 / NumberOfBomFloatM5 end end as BomRatioM6M5,
case when NumberOfBomDeltaFloatM7M6 = 0 then 0 else case when NumberOfBomFloatM6 = 0
then 0 else NumberOfBomDeltaFloatM7M6 / NumberOfBomFloatM6 end end as BomRatioM7M6,
case when NumberOfBomDeltaFloatM8M7 = 0 then 0 else case when NumberOfBomFloatM7 = 0
then 0 else NumberOfBomDeltaFloatM8M7 / NumberOfBomFloatM7 end end as BomRatioM8M7,
case when NumberOfBomDeltaFloatM9M8 = 0 then 0 else case when NumberOfBomFloatM8 = 0
then 0 else NumberOfBomDeltaFloatM9M8 / NumberOfBomFloatM8 end end as BomRatioM9M8,
case when NumberOfBomDeltaFloatM10M9 = 0 then 0 else case when NumberOfBomFloatM9 = 0
then 0 else NumberOfBomDeltaFloatM10M9 / NumberOfBomFloatM9 end end as BomRatioM10M9,
// Consumption Intervall as number of consecutive previous Month withour Consumption
0 as ConsumptionIntervalM1,
case when ConsumptionQtyM1 > 0 then 0 else 1 end as ConsumptionIntervalM2,
case when ConsumptionQtyM2 > 0 then 0 else case when ConsumptionQtyM1 > 0 then 1 else 2 end end as ConsumptionIntervalM3,
case when ConsumptionQtyM3 > 0 then 0 else case when ConsumptionQtyM2 > 0 then 1
else case when ConsumptionQtyM1 > 0 then 2 else 3 end end end as ConsumptionIntervalM4,
case when ConsumptionQtyM4 > 0 then 0 else case when ConsumptionQtyM3 > 0 then 1
else case when ConsumptionQtyM2 > 0 then 2
else case when ConsumptionQtyM1 > 0 then 3 else 4 end end end end as ConsumptionIntervalM5,
case when ConsumptionQtyM5 > 0 then 0 else case when ConsumptionQtyM4 > 0 then 1
else case when ConsumptionQtyM3 > 0 then 2
else case when ConsumptionQtyM2 > 0 then 3
else case when ConsumptionQtyM1 > 0 then 4 else 5 end end end end end as ConsumptionIntervalM6
}