P_RSHExMuDayOpsForSchedCapPrWD

DDL: P_RSHEXMUDAYOPSFORSCHEDCAPPRWD SQL: PRSHMUOPINSCDPWD Type: view CONSUMPTION

Operation Capacity Per Work Day

P_RSHExMuDayOpsForSchedCapPrWD is a Consumption CDS View that provides data about "Operation Capacity Per Work Day" in SAP S/4HANA. It reads from 2 data sources (P_RSHCALWORKDAYS, P_RSHExMuDayOpsForSchedCapPrDy) and exposes 24 fields with key fields CapacityInternalID, MaintenanceOrder, MaintenanceOrderOperation, MaintenanceOrderSubOperation, CapacityStartTime.

Data Sources (2)

SourceAliasJoin Type
P_RSHCALWORKDAYS P_RSHCALWORKDAYS inner
P_RSHExMuDayOpsForSchedCapPrDy P_RSHExMuDayOpsForSchedCapPrDy from

Parameters (2)

NameTypeDefault
P_StartDate datum
P_EndDate datum

Annotations (8)

NameValueLevelField
AbapCatalog.sqlViewName PRSHMUOPINSCDPWD view
AbapCatalog.compiler.compareFilter true view
AccessControl.authorizationCheck #NOT_REQUIRED view
VDM.private true view
VDM.viewType #CONSUMPTION view
AbapCatalog.preserveKey true view
EndUserText.label Operation Capacity Per Work Day view
ClientHandling.algorithm #SESSION_VARIABLE view

Fields (24)

KeyFieldSource TableSource FieldDescription
KEY CapacityInternalID OperationCapacityPerShift CapacityInternalID
KEY MaintenanceOrder OperationCapacityPerShift MaintenanceOrder
KEY MaintenanceOrderOperation OperationCapacityPerShift MaintenanceOrderOperation
KEY MaintenanceOrderSubOperation OperationCapacityPerShift MaintenanceOrderSubOperation
KEY CapacityStartTime OperationCapacityPerShift CapacityStartTime
KEY AvailableCapacityShift OperationCapacityPerShift AvailableCapacityShift
KEY CalendarDate OperationCapacityPerShift CalendarDate
ProcessingStatus OperationCapacityPerShift ProcessingStatus
OrderType OperationCapacityPerShift OrderType
MaintenanceActivityType OperationCapacityPerShift MaintenanceActivityType
MaintPriority OperationCapacityPerShift MaintPriority
MaintPriorityType OperationCapacityPerShift MaintPriorityType
MaintPriorityColorCode OperationCapacityPerShift MaintPriorityColorCode
OperationControlKey OperationCapacityPerShift OperationControlKey
WorkCenter OperationCapacityPerShift WorkCenter
WorkCenterInternalID OperationCapacityPerShift WorkCenterInternalID
WorkCenterCategoryCode OperationCapacityPerShift WorkCenterCategoryCode
Plant OperationCapacityPerShift Plant
WorkCenterTypeCode OperationCapacityPerShift WorkCenterTypeCode
OperatingDurationInSeconds OperationCapacityPerShift OperatingDurationInSeconds
TotOperatingDurationInSeconds OperationCapacityPerShift TotOperatingDurationInSeconds
OperationPlannedWork OperationCapacityPerShift OperationPlannedWork
OperationDayCount OperationCapacityPerShift OperationDayCount
OperationPersonResponsible OperationCapacityPerShift OperationPersonResponsible
@AbapCatalog.sqlViewName: 'PRSHMUOPINSCDPWD'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.private: true
@VDM.viewType: #CONSUMPTION
@AbapCatalog.preserveKey: true
@EndUserText.label: 'Operation Capacity Per Work Day'
@ClientHandling.algorithm: #SESSION_VARIABLE

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

Name:                       Multiday Operations Capacity Per Daily Shift
Specification:              This view checks whether each day is working and returns capacity accordingly
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_RSHExMuDayOpsForSchedCapPrWD
  with parameters
    P_StartDate : datum,
    P_EndDate   : datum



  as select from P_RSHExMuDayOpsForSchedCapPrDy(P_StartDate : $parameters.P_StartDate,
                                                P_EndDate : $parameters.P_EndDate) as OperationCapacityPerShift

    inner join   P_RSHCALWORKDAYS( P_SAPClient : $session.client )                 as isWorkDay on  OperationCapacityPerShift.CapacityInternalID  = isWorkDay.CapacityInternalID
                                                                                                and OperationCapacityPerShift.FactoryCalendarDate = isWorkDay.CalendarDate

{

  key OperationCapacityPerShift.CapacityInternalID           as CapacityInternalID,
  key OperationCapacityPerShift.MaintenanceOrder             as MaintenanceOrder,
  key OperationCapacityPerShift.MaintenanceOrderOperation    as MaintenanceOrderOperation,
  key OperationCapacityPerShift.MaintenanceOrderSubOperation as MaintenanceOrderSubOperation,
  key OperationCapacityPerShift.CapacityStartTime            as CapacityStartTime,
  key OperationCapacityPerShift.AvailableCapacityShift       as AvailableCapacityShift,
  key OperationCapacityPerShift.CalendarDate                 as CalendarDate,

      //     isStartDay,

      //     isEndDay,


      OperationCapacityPerShift.ProcessingStatus             as ProcessingStatus,
      OperationCapacityPerShift.OrderType                    as OrderType,
      OperationCapacityPerShift.MaintenanceActivityType      as MaintenanceActivityType,
      OperationCapacityPerShift.MaintPriority                as MaintPriority,
      OperationCapacityPerShift.MaintPriorityType            as MaintPriorityType,
      OperationCapacityPerShift.MaintPriorityColorCode       as MaintPriorityColorCode,
      OperationCapacityPerShift.OperationControlKey          as OperationControlKey,
      OperationCapacityPerShift.WorkCenter,
      OperationCapacityPerShift.WorkCenterInternalID         as WorkCenterInternalID,
      OperationCapacityPerShift.WorkCenterCategoryCode       as WorkCenterCategoryCode,
      OperationCapacityPerShift.Plant                        as Plant,
      OperationCapacityPerShift.WorkCenterTypeCode           as WorkCenterTypeCode,


      OperationCapacityPerShift.OperatingDurationInSeconds,
      OperationCapacityPerShift.TotOperatingDurationInSeconds,
      OperationCapacityPerShift.OperationPlannedWork         as OperationPlannedWork,
      OperationCapacityPerShift.OperationDayCount            as OperationDayCount,

      -- This view calculates the time in the capacity shift opening hours that is not covered by a multi-day operation on the operation start or end date
      -- On days that are between the operation start and end, no such time can occur, since the operations covers the whole day
      -- We call this uncovered time: Capacity Gap
      -- On the start date the gap is the time between the start of the operation and the start of the capacity
      -- On the end date the gap is the time between the end of the capacity and the end of the operation

      case
         when isWorkDay.WorkDays = 0 and OperationCapacityPerShift.WorkDayRule = '' or
              OperationCapacityPerShift.WorkDayRule = '0' or
              OperationCapacityPerShift.CapacityEndTime = OperationCapacityPerShift.CapacityStartTime or
              OperationCapacityPerShift.TotOperatingDurationInSeconds = 0
         then 0
         else
      OperationCapacityPerShift.CalCapacityInParallel
      end                                                    as CalCapacityInParallel,

      OperationCapacityPerShift.OperationPersonResponsible   as OperationPersonResponsible
}