P_STOCKLEVELMNGCALCFIELDS

CDS View

P_STOCKLEVELMNGCALCFIELDS is a CDS View in S/4HANA. It contains 32 fields. 1 CDS views read from this table.

CDS Views using this table (1)

ViewTypeJoinVDMDescription
P_StockLevelMngNumFields view from CONSUMPTION

Fields (32)

KeyField CDS FieldsUsed in Views
KEY ProposalStartDate ProposalStartDate 1
KEY ProposalVersion ProposalVersion 1
AvgDailyUsageUnit AvgDailyUsageUnit 1
BufferLevelStartDate BufferLevelStartDate 1
CurrentAvgDailyUsage CurrentAverageDailyUsage 1
CurrentLeadTime CurrentLeadTime 1
CurrentLeadTimeFactor CurrentLeadTimeFactor 1
CurrentMatlLeadTimeCode CurrentMatlLeadTimeCode 1
CurrentMatlVariabilityCode CurrentMatlVariabilityCode 1
CurrentVariabilityFactor CurrentVariabilityFactor 1
DifferenceInDaysDesc DifferenceInDaysDesc 1
MatlPrpslAdjmtFctrIsApplied MatlPrpslAdjmtFctrIsApplied 1
ProcurementTypeDescription ProcurementTypeDescription 1
ProposalEndDate ProposalEndDate 1
ProposedAverageDailyUsage ProposedAverageDailyUsage 1
ProposedLeadTime ProposedLeadTime 1
ProposedLeadTimeFactor ProposedLeadTimeFactor 1
ProposedMaterialBufferProfile ProposedMaterialBufferProfile 1
ProposedMatlBufferProfileText ProposedMatlBufferProfileText 1
ProposedMatlLeadTime ProposedMatlLeadTime 1
ProposedMatlLeadTimeCode ProposedMatlLeadTimeCode 1
ProposedMatlVariabilityCode ProposedMatlVariabilityCode 1
ProposedMatlVariabilityQty ProposedMatlVariabilityQty 1
ProposedMatlVariabilityUnit ProposedMatlVariabilityUnit 1
ProposedVariabilityFactor ProposedVariabilityFactor 1
ReplenishmentLeadTimeDesc ReplenishmentLeadTimeDesc 1
ReplenishmentLeadTimeValue ReplenishmentLeadTimeValue 1
StockLevelProposalID StockLevelProposalID 1
StockLevelProposalStatus StockLevelProposalStatus 1
VariabilityDescription VariabilityDescription 1
VariabilityQuantity VariabilityQuantity 1
VariabilityUnit VariabilityUnit 1
@AbapCatalog.sqlViewName: 'PSTKLVLMNGCF'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ClientHandling.algorithm: #SESSION_VARIABLE



@VDM.private: true
@VDM.viewType:#CONSUMPTION
define view P_StockLevelMngCalcFields
  as select from I_StockLevelProposal as _StockProposed
  association [1..*] to P_TimeDependentStockBuffer as _StockActual   on  $projection.Material = _StockActual.Material
                                                                     and $projection.Plant    = _StockActual.Plant
                                                                     and $projection.MRPArea  = _StockActual.MRPArea

  association [1..1] to I_DemandDrivenProduct      as _Product       on  $projection.Material = _Product.Material
                                                                     and $projection.Plant    = _Product.Plant
                                                                     and $projection.MRPArea  = _Product.MRPArea



{

  key _StockProposed.Material,
  key _StockProposed.Plant,
  key _StockProposed.MRPArea,
  key _StockProposed.ProposalStartDate,
  key _StockProposed.ProposalVersion,
      _StockActual.CurrentRedZone,
      _StockActual.CurrentLeadTime,
      _StockActual.CurrentLeadTimeFactor,
      _StockActual.CurrentVariabilityFactor,
      _StockActual.BufferLevelStartDate,
      _StockActual.CurrentGreenZone,
      _StockActual.CurrentYellowZone,
      _StockActual.CurrentAvgDailyUsage                                                                                                                                                                                                    as  CurrentAvgDailyUsage,

      _StockProposed.BillOfMaterialUUID,
      _StockActual.BillOfMaterialUUID                                                                                                                                                                                                      as  ProposedBOMUUID,

      
      _StockProposed.ProposalEndDate,
      _StockProposed.AverageDailyUsage as ProposedAverageDailyUsage,
      _StockProposed.ProposedGreenZone,
      _StockProposed.ProposedRedZone,
      _StockProposed.ProposedYellowZone,
      _StockProposed.DecoupledLeadTime as ProposedLeadTime,
      _StockProposed.LeadTimeFactor                                                                                                                                                                                                        as  ProposedLeadTimeFactor,
      _StockProposed.VariabilityFactor as ProposedVariabilityFactor,
      _StockProposed.StockLevelProposalID,
      _StockProposed.StockLevelProposalStatus,
      _StockProposed.AvgDailyUsageUnit,


      DATS_DAYS_BETWEEN(tstmp_to_dats( _StockProposed.ProposalStatusChangeDate,
                     abap_system_timezone( $session.client,'NULL' ),
                     $session.client,
                     'NULL' ), cast($session.system_date as sydatum))                                                                                                                                    as  DifferenceInDays,



      _StockActual.VariabilityQuantity,
      _StockActual.VariabilityUnit,
      _StockActual.ReplenishmentLeadTimeValue,
      _StockActual.ReplenishmentLeadTimeCode                                                                                                                                                                                               as  CurrentMatlLeadTimeCode,
      _StockActual.VariabilityCode                                                                                                                                                                                                         as  CurrentMatlVariabilityCode,
      _StockProposed.VariabilityCode                                                                                                                                                                                                       as  ProposedMatlVariabilityCode,
      _StockProposed.VariabilityQuantity                                                                                                                                                                                                   as  ProposedMatlVariabilityQty,
      _StockProposed.VariabilityUnit                                                                                                                                                                                                       as  ProposedMatlVariabilityUnit,
      _StockProposed.ReplenishmentLeadTimeCode                                                                                                                                                                                             as  ProposedMatlLeadTimeCode,
      _StockProposed.ReplenishmentLeadTimeValue                                                                                                                                                                                            as  ProposedMatlLeadTime,
      



     
      cast( _Product.HorizonDaysInPast as abap.int4) + cast( _Product.HorizonDaysInFuture as abap.int4)                                                                                                                                    as  TotalNoOfDays,

      case DATS_DAYS_BETWEEN(tstmp_to_dats( _StockProposed.ProposalStatusChangeDate,
                     abap_system_timezone( $session.client,'NULL' ),
                     $session.client,
                     'NULL' ), cast($session.system_date as sydatum))
      when 0
      then '0'
      when 1
      then '1'
      else '2'
      end                                                                                                                                                                                                                                  as  DifferenceInDaysDesc,


      case
      when _StockActual.CurrentRedZone is null
      then  _StockProposed.OriglProposedRedZone
      else  _StockProposed.OriglProposedRedZone - _StockActual.CurrentRedZone
      end                                                                                                                                                                                                                                  as  RedZoneDifference,
      case
      when _StockActual.CurrentYellowZone is null
      then  _StockProposed.OriglProposedYellowZone
      else   _StockProposed.OriglProposedYellowZone - _StockActual.CurrentYellowZone
      end                                                                                                                                                                                                                                  as  YellowZoneDifference,
      case
      when _StockActual.CurrentGreenZone is null
      then _StockProposed.OriglProposedGreenZone
      else  _StockProposed.OriglProposedGreenZone - _StockActual.CurrentGreenZone
      end                                                                                                                                                                                                                                  as  GreenZoneDifference,
      case
      when _StockActual.CurrentAvgDailyUsage      is  null
      then  _StockProposed.AverageDailyUsage
      else   _StockProposed.AverageDailyUsage  - _StockActual.CurrentAvgDailyUsage
      end                                                                                                                                                                                                                                  as  AvgDailyUsageDifference,


      case
      when  _StockActual.CurrentAvgDailyUsage = 0.000 or _StockActual.CurrentAvgDailyUsage is  null
      then
       case
       when _StockProposed.AverageDailyUsage <> 0.000
       then fltp_to_dec(99999.99 as abap.dec(12,2))
       else    0.00
       end
      else       cast((_StockProposed.AverageDailyUsage  - _StockActual.CurrentAvgDailyUsage) as abap.fltp)/(cast((_StockActual.CurrentAvgDailyUsage) as abap.fltp))*100.00
      end                                                                                                                                                                                                                                  as  AvgDailyUsageDeviationRate,

      case
      when _StockActual.CurrentLeadTimeFactor is null
      then  _StockProposed.LeadTimeFactor
      else _StockProposed.LeadTimeFactor  - _StockActual.CurrentLeadTimeFactor
      end                                                                                                                                                                                                                                  as  LeadTimeFactorDifference,


      case
      when   _StockActual.CurrentLeadTimeFactor is null or _StockActual.CurrentLeadTimeFactor = 0.00
      then
        case
        when _StockProposed.LeadTimeFactor <> 0.00
        then  fltp_to_dec(99999.99 as abap.dec(12,2))
        else 0
        end
      else
      cast((_StockProposed.LeadTimeFactor  - _StockActual.CurrentLeadTimeFactor) as abap.fltp)/(cast((_StockActual.CurrentLeadTimeFactor) as abap.fltp))*100.00
      end                                                                                                                                                                                                                                  as  LeadTimeFactorDeviationRate,

      case
      when _StockActual.CurrentLeadTime is null
      then  _StockProposed.DecoupledLeadTime
      else _StockProposed.DecoupledLeadTime  - _StockActual.CurrentLeadTime
      end                                                                                                                                                                                                                                  as  LeadTimeDifference,



      case
      when  _StockActual.CurrentLeadTime =  0.00 or _StockActual.CurrentLeadTime is   null
      then
         case
         when _StockProposed.DecoupledLeadTime <> 0.00
         then fltp_to_dec(99999.99 as abap.dec(12,2))
         else    0.00
         end
      else
      cast((_StockProposed.DecoupledLeadTime  - _StockActual.CurrentLeadTime) as abap.fltp)/(cast((_StockActual.CurrentLeadTime) as abap.fltp))*100.00
      end                                                                                                                                                                                                                                  as  LeadTimeDeviationRate,

      case
      when  _StockActual.VariabilityQuantity  is null
      then _StockProposed.VariabilityQuantity
      else
      _StockProposed.VariabilityQuantity  - _StockActual.VariabilityQuantity
      end                                                                                                                                                                                                                                  as  VariabilityFactorDifference,


      case
      when  _StockActual.VariabilityQuantity  = 0.00 or _StockActual.VariabilityQuantity  is   null
      then
      case
      when _StockProposed.VariabilityQuantity  <> 0.00
      then fltp_to_dec(99999.99 as abap.dec(12,2))
      else    0.00
      end
      else cast((_StockProposed.VariabilityQuantity   - _StockActual.VariabilityQuantity ) as abap.fltp)/(cast((_StockActual.VariabilityQuantity ) as abap.fltp))*100.00
      end                                                                                                                                                                                                                                  as  VariabilityFactorDeviationRate,



      _StockProposed.ProposedGreenZone +  _StockProposed.ProposedYellowZone + _StockProposed.ProposedRedZone                                                                                                                               as  MatlProposedMaxStock,
      case
      when _StockActual.MaterialMaxStockLevelQuantity is null
      then  _StockProposed.OriglProposedGreenZone +  _StockProposed.OriglProposedYellowZone + _StockProposed.OriglProposedRedZone
      else
      _StockProposed.OriglProposedGreenZone +  _StockProposed.OriglProposedYellowZone + _StockProposed.OriglProposedRedZone -  _StockActual.MaterialMaxStockLevelQuantity
      end                                                                                                                                                                                                                                  as  MaxStockDifference,
      case
      when _StockActual.MaterialMaxStockLevelQuantity is null
      then 0
      else _StockActual.MaterialMaxStockLevelQuantity
      end                                                                                                                                                                                                                                  as  MaterialMaxStockLevelQuantity,

      case
      when  _StockActual.CurRedZoneAdjustmentFctr <> 1 or  _StockActual.CurYellowZoneAdjustmentFctr <> 1 or _StockActual.CurGreenZoneAdjustmentFctr <> 1
      then cast('X' as xfeld)
      else cast(' ' as xfeld )
      end                                                                                                                                                                                                                                  as  MatlPrpslAdjmtFctrIsApplied,


      concat(_StockProposed.ProcurementType,concat('-',concat(concat(_StockProposed.VariabilityCode,'-'),_StockProposed.ReplenishmentLeadTimeCode)))                                                                                       as  ProposedMaterialBufferProfile,
      concat(_StockProposed._ProcmtText.ProcurementTypeDescription,concat('-',concat(concat(_StockProposed._VarText.VariabilityDescription,'-'),_StockProposed._ReplnmtText.ReplenishmentLeadTimeDesc)))                                                                     as  ProposedMatlBufferProfileText,


        _ProcmtText.ProcurementTypeDescription,
        _VarText.VariabilityDescription,
        _ReplnmtText.ReplenishmentLeadTimeDesc, 
      
      

      _StockProposed.IsMinOrderQtyConsidered,
      cast(_Product.HorizonDaysInPast as abap.int2)                                                                                                                                                                                        as  HorizonDaysInPast,
      _StockActual,
      _Product
      
      
      
     







}
where
  _StockProposed.ProposalEndDate = '99991231'
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_DEMANDDRIVENPRODUCT",
"I_PROCUREMENTTYPETEXT",
"I_REPLENISHMENTLEADTIMETEXT",
"I_STOCKLEVELPROPOSAL",
"I_VARIABILITYTEXT",
"P_TIMEDEPENDENTSTOCKBUFFER"
],
"ASSOCIATED":
[
"I_DEMANDDRIVENPRODUCT",
"P_TIMEDEPENDENTSTOCKBUFFER"
],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/