P_RSHEXMUDAYOPSFORSCHEDCAPPRDY

CDS View

Operation Consumption View

P_RSHEXMUDAYOPSFORSCHEDCAPPRDY is a CDS View in S/4HANA. Operation Consumption View. 1 CDS views read from this table.

CDS Views using this table (1)

ViewTypeJoinVDMDescription
P_RSHExMuDayOpsForSchedCapPrWD view from CONSUMPTION Operation Capacity Per Work Day
@AbapCatalog.sqlViewName: 'PRSHOPFRSCHDCPD'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.private: true
@VDM.viewType: #CONSUMPTION
@AbapCatalog.preserveKey: true
@ClientHandling.algorithm: #SESSION_VARIABLE

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

Name:                       Multiday Operations Capacity Per Daily Shift
Specification:              This view creates a daily record per operation and shift and calculates the capacity in parallel.
Requires:                   NA
Ensures:                    At Start and End Date only the covered portion of capacity is returned as capacity in parallel.
                            Intermediate dates take full shift capacity.
                            Factory Calendar, Work Day Rule definition of capacity interval resp. shift is considered.
                            E.g. If a day is non working day as per factory calendar no capacity is considered for such day.
Owners:                     PRP
Contributors:               AN
Unit Test required Y/N:     Yes
Additional comments         None

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


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


  as select from P_RSHExMuDayOpsForSched(P_StartDate : $parameters.P_StartDate, P_EndDate : $parameters.P_EndDate)        as WorkCenterOperation


    inner join   P_RSHCapInExOpsPeriodForSched (P_StartDate : $parameters.P_StartDate, P_EndDate : $parameters.P_EndDate) as date_series on  date_series.CapacityInternalID =  WorkCenterOperation.CapacityInternalID
                                                                                                                                         and date_series.CalendarDate       <= WorkCenterOperation.PlannedEndDate
                                                                                                                                         and date_series.CalendarDate       >= WorkCenterOperation.PlannedStartDate


{

  key  date_series.CapacityInternalID,

  key  MaintenanceOrder                               as MaintenanceOrder,
  key  MaintenanceOrderOperation                      as MaintenanceOrderOperation,
  key  MaintenanceOrderSubOperation                   as MaintenanceOrderSubOperation,

  key  date_series.CalendarDate                       as CalendarDate,

  key  CapacityStartTime,
  key  AvailableCapacityShift,
       date_series.WorkDays,


       //      case when ValidityBeginDate = date_series.CalendarDate

       //           then 'X' end                                                                                                       as  isStartDay,

       //

       //      case when ValidityEndDate = date_series.CalendarDate

       //           then 'X' end                                                                                                       as  isEndDay,


       NightSplitDate,
       AvailableCapacityIntervalDurn,
       date_series.WeekDay,
       WorkDayRule,
       FactoryCalendar,
       CapacityEndTime,
       OperationControlKey,
       OrderType,
       MaintenanceActivityType,
       MaintPriority,
       MaintPriorityType,
       MaintPriorityColorCode,
       ProcessingStatus,
       WorkCenterOperation.WorkCenter,
       WorkCenterOperation.WorkCenterInternalID,
       WorkCenterCategoryCode,
       Plant,
       WorkCenterOperation.WorkCenterTypeCode,
       OperationPlannedWork,
       OperationPlannedWorkUnit,
       PlannedStartDate,
       PlannedStartTime,
       PlannedStartTimeInSeconds,
       PlannedEndDate,
       PlannedEndTime,
       PlannedEndTimeInSeconds,
       OperationDayCount,
       OperatingDurationInSeconds,
       TotOperatingDurationInSeconds,

       case when NightSplitDate = 2
            then dats_add_days(CalendarDate, -1, 'FAIL')
            else CalendarDate
       end                                            as FactoryCalendarDate,

       -- if the capacity date is not on the start date and not on the end date of the operation, it must be between these dates
       -- on these days, the operation fully spans the shift and hence always consumes te entire shift capacity
       (case
         when ( date_series.CalendarDate > PlannedStartDate and
                date_series.CalendarDate < PlannedEndDate )      -- capacity on fully covered days
         then OperatingDurationInSeconds
         else
       -- If the operation ends after the capacity starts, we calculate the available capacity
       -- Example:
       -- Capacity 09:00 to 17:00 with 1 hour break duration. Operation end 16:00, start on another day
       -- OperatingDurationInHours is 17 - 9 - 1 = 7 hours (in seconds)

       -- This calculation determines the capacity in this shift available for the operation by
       -- ( 57.600 (OperationEndTime) - 32.400 (CapacityStartTime) )      / ( 61.200 (CapacityEndTime) - 32.400 (CapacityStartTime) ) * 25.200 (OperatingDurationInHours)
       -- = 25.200 (Opening Hours in parallel to operation in this shift) / 28.800 (total opening hours of this shift)                * 25.200 (Single resource capacity of the shift)
       -- = 22.050 (Single resource capacity of the shift available to the operation)

       -- In case Capacity Calendar Date is same as Operation Start date.
             case
               when  date_series.CalendarDate = PlannedStartDate
               then
                   case -- check if Capacity is already been ended before Operation start date then there is no capacity consider 0
                     when PlannedStartTimeInSeconds >= CapacityEndTime
                     then 0
                     else -- in case Capacity falls under Operation start date
                         case
                           when ( PlannedStartTimeInSeconds > CapacityStartTime )
                           then -- in case Capacity start time is before Operation planned start time, then calaculate the use subtract the PlannedStartTimeInSeconds
                                cast( CapacityEndTime - PlannedStartTimeInSeconds as abap.fltp) /
                                cast( CapacityEndTime - CapacityStartTime          as abap.fltp) * cast(OperatingDurationInSeconds  as abap.fltp)
                           else -- in case Operation start time is before Capacity start time then no need to calculate
                                OperatingDurationInSeconds
                         end
                   end
       -- In case Capacity Calendar Date is same as Operation End date.
               else
                   case
                     when date_series.CalendarDate = PlannedEndDate
                     then
                         case
                           when (PlannedEndTimeInSeconds <= CapacityStartTime)
                           then 0
                           else
                             case
                               when PlannedEndTimeInSeconds < CapacityEndTime
                               then -- in case Capacity end time is after Operation planned end time, then subtract from PlannedEndTime
                                    cast ( PlannedEndTimeInSeconds - CapacityStartTime  as abap.fltp) /
                                    cast ( CapacityEndTime          - CapacityStartTime  as abap.fltp) * cast(OperatingDurationInSeconds as abap.fltp)
                               else -- in case Operation end time is after Capacity end time then no need to calculate
                                 OperatingDurationInSeconds
                             end
                         end
                     else 0
                   end
             end
       end)                                           as CalCapacityInParallel,

       WorkCenterOperation.OperationPersonResponsible as OperationPersonResponsible

}