P_RSHCapInExOpsPeriodForSched

DDL: P_RSHCAPINEXOPSPERIODFORSCHED SQL: PRSHCAPINOPPER Type: view CONSUMPTION Package: RSH_CDS_MAINT_SCHED_SIM

Capacity of work center in the operation time frame

P_RSHCapInExOpsPeriodForSched is a Consumption CDS View that provides data about "Capacity of work center in the operation time frame" in SAP S/4HANA. It reads from 2 data sources (P_RSHCALWORKDAYS, P_RSHWCCapWNightsForSchedOpTme) and exposes 22 fields with key field CapacityInternalID. Part of development package RSH_CDS_MAINT_SCHED_SIM.

Data Sources (2)

SourceAliasJoin Type
P_RSHCALWORKDAYS P_RSHCALWORKDAYS from
P_RSHWCCapWNightsForSchedOpTme P_RSHWCCapWNightsForSchedOpTme inner

Parameters (2)

NameTypeDefault
P_StartDate datum
P_EndDate datum

Annotations (7)

NameValueLevelField
AbapCatalog.sqlViewName PRSHCAPINOPPER view
AccessControl.authorizationCheck #NOT_REQUIRED view
VDM.private true view
VDM.viewType #CONSUMPTION view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
ClientHandling.algorithm #SESSION_VARIABLE view

Fields (22)

KeyFieldSource TableSource FieldDescription
KEY CapacityInternalID date_series CapacityInternalID
FactoryCalendarDate CalendarDate
WeekDay date_series WeekDay
WorkDays date_series WorkDays
ValidityEndDate WorkCenterCapacity ValidityEndDate
AvailableCapacityShift WorkCenterCapacity AvailableCapacityShift
CapacityStartTime WorkCenterCapacity CapacityStartTime
ValidityBeginDate WorkCenterCapacity ValidityBeginDate
NightSplitDate WorkCenterCapacity NightSplitDate
AvailableCapacityIntervalDurn WorkCenterCapacity AvailableCapacityIntervalDurn
WorkDayRule WorkCenterCapacity WorkDayRule
CapacityEndTime WorkCenterCapacity CapacityEndTime
TotOperatingDurationInSeconds WorkCenterCapacity TotOperatingDurationInSeconds
OperatingDurationInSeconds WorkCenterCapacity OperatingDurationInSeconds
CapacityNumberOfCapacities WorkCenterCapacity CapacityNumberOfCapacities
CapacityPlanUtilizationPercent WorkCenterCapacity CapacityPlanUtilizationPercent
WorkCenterInternalID WorkCenterCapacity WorkCenterInternalID
WorkCenter WorkCenterCapacity WorkCenter
WorkCenterCategoryCode WorkCenterCapacity WorkCenterCategoryCode
WorkCenterTypeCode WorkCenterCapacity WorkCenterTypeCode
Plant WorkCenterCapacity Plant
FactoryCalendar WorkCenterCapacity FactoryCalendar
@AbapCatalog.sqlViewName: 'PRSHCAPINOPPER'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.private: true
@VDM.viewType: #CONSUMPTION
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@ClientHandling.algorithm: #SESSION_VARIABLE

/*
CONTRACT**********************************************************************************************************************

Name:                       Work Center Capacity in Operations Time Frame
Specification:              This view will return work center capacity between effective/largest date interval that is spanned by the operations
                            and sub operations under the maintenance orders as well as under the maintenance plans (The Maintenance Plan interval
                            will be same as the incoming period, since maintencne plan operations will not span more
                            than one day)
Requires:                   NA
Ensures:                    Work Center Capacity in Operations Time Frame is returned
Owners:                     PRP
Contributors:               CK, AN
Unit Test required Y/N:     Yes
Additional comments         None

END OF CONTRACT***************************************************************************************************************
*/

define view P_RSHCapInExOpsPeriodForSched
  with parameters
    P_StartDate : datum,
    P_EndDate   : datum

  as select from P_RSHCALWORKDAYS( P_SAPClient : $session.client )                                                        as date_series

    inner join   P_RSHWCCapWNightsForSchedOpTme(P_StartDate : $parameters.P_StartDate, P_EndDate : $parameters.P_EndDate) as WorkCenterCapacity on  WorkCenterCapacity.CapacityInternalID             =       date_series.CapacityInternalID
                                                                                                                                                and date_series.CalendarDate                          between WorkCenterCapacity.ValidityBeginDate and WorkCenterCapacity.ValidityEndDate

                                                                                                                                                and (
                                                                                                                                                   (
                                                                                                                                                     WorkCenterCapacity.AvailableCapacityIntervalDurn =       '01'
                                                                                                                                                   )     // 1 day shift interval duration

                                                                                                                                                   or(
                                                                                                                                                     WorkCenterCapacity.AvailableCapacityIntervalDurn =       '07'
                                                                                                                                                     and // 7 day shift interval duration

                                                                                                                                                     date_series.WeekDay                              =       WorkCenterCapacity.WeekDay
                                                                                                                                                   )
                                                                                                                                                 )

{

  key date_series.CapacityInternalID,
  key case when WorkCenterCapacity.DayOffset = 1
           then dats_add_days(CalendarDate, 1, 'FAIL')
           when WorkCenterCapacity.DayOffset = -1
           then dats_add_days(CalendarDate, -1, 'FAIL')
      else
           CalendarDate end as CalendarDate,
      CalendarDate          as FactoryCalendarDate,
      date_series.WeekDay,
      date_series.WorkDays,

      WorkCenterCapacity.ValidityEndDate,
      WorkCenterCapacity.AvailableCapacityShift,
      WorkCenterCapacity.CapacityStartTime,
      WorkCenterCapacity.ValidityBeginDate,
      WorkCenterCapacity.NightSplitDate,
      WorkCenterCapacity.AvailableCapacityIntervalDurn,
      WorkCenterCapacity.WorkDayRule,
      WorkCenterCapacity.CapacityEndTime,
      WorkCenterCapacity.TotOperatingDurationInSeconds,
      WorkCenterCapacity.OperatingDurationInSeconds,
      WorkCenterCapacity.CapacityNumberOfCapacities,
      WorkCenterCapacity.CapacityPlanUtilizationPercent,
      WorkCenterCapacity.WorkCenterInternalID,
      WorkCenterCapacity.WorkCenter,
      WorkCenterCapacity.WorkCenterCategoryCode,
      WorkCenterCapacity.WorkCenterTypeCode,
      WorkCenterCapacity.Plant,
      WorkCenterCapacity.FactoryCalendar
}

where
  date_series.CalendarDate between WorkCenterCapacity.OperationTImeFrameStartDate and WorkCenterCapacity.OperationTImeFrameEndDate