@AbapCatalog.sqlViewName: 'PSLOWMOMATCODELT'
@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_SlowMoMatPrMoCnsmpnDelta as select from P_SlowMoMatPrMoCnsmpnFloat 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.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
ConsumptionDeltaM2M1,
ConsumptionDeltaM3M2,
ConsumptionDeltaM4M3,
ConsumptionDeltaM5M4,
ConsumptionDeltaM6M5,
//Ratio Consumption Delta Month to previous Month devided by Consumption of Pervious Month
case when ConsumptionDeltaM2M1 = 0 then 0 else case when ConsumptionQtyM1 = 0
then 0 else ConsumptionDeltaM2M1 / ConsumptionQtyM1 end end as ConsumptionRatioM2M1,
case when ConsumptionDeltaM3M2 = 0 then 0 else case when ConsumptionQtyM2 = 0
then 0 else ConsumptionDeltaM3M2 / ConsumptionQtyM2 end end as ConsumptionRatioM3M2,
case when ConsumptionDeltaM4M3 = 0 then 0 else case when ConsumptionQtyM3 = 0
then 0 else ConsumptionDeltaM4M3 / ConsumptionQtyM3 end end as ConsumptionRatioM4M3,
case when ConsumptionDeltaM5M4 = 0 then 0 else case when ConsumptionQtyM4 = 0
then 0 else ConsumptionDeltaM5M4 / ConsumptionQtyM4 end end as ConsumptionRatioM5M4,
case when ConsumptionDeltaM6M5 = 0 then 0 else case when ConsumptionQtyM5 = 0
then 0 else ConsumptionDeltaM6M5 / ConsumptionQtyM5 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
NumberOfBomDeltaM6M5,
NumberOfBomDeltaM7M6,
NumberOfBomDeltaM8M7,
NumberOfBomDeltaM9M8,
NumberOfBomDeltaM10M9,
//Ratio Number of BOMs Delta Month to previous Month devided by Number of BOMs of Pervious Month
case when NumberOfBomDeltaM6M5 = 0 then 0 else case when NumberOfBomM5 = 0
then 0 else NumberOfBomDeltaM6M5 / NumberOfBomM5 end end as BomRatioM6M5,
case when NumberOfBomDeltaM7M6 = 0 then 0 else case when NumberOfBomM6 = 0
then 0 else NumberOfBomDeltaM7M6 / NumberOfBomM6 end end as BomRatioM7M6,
case when NumberOfBomDeltaM8M7 = 0 then 0 else case when NumberOfBomM7 = 0
then 0 else NumberOfBomDeltaM8M7 / NumberOfBomM7 end end as BomRatioM8M7,
case when NumberOfBomDeltaM9M8 = 0 then 0 else case when NumberOfBomM8 = 0
then 0 else NumberOfBomDeltaM9M8 / NumberOfBomM8 end end as BomRatioM9M8,
case when NumberOfBomDeltaM10M9 = 0 then 0 else case when NumberOfBomM9 = 0
then 0 else NumberOfBomDeltaM10M9 / NumberOfBomM9 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
}
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_PRODUCT",
"P_SLOWMOMATPRMOCNSMPNFLOAT"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/