P_RSHSMLTDOPINSECONDS

CDS View

P_RSHSMLTDOPINSECONDS is a CDS View in S/4HANA. It contains 8 fields. 2 CDS views read from this table.

CDS Views using this table (2)

ViewTypeJoinVDMDescription
P_RSHSmltdOpCapacity view from CONSUMPTION
P_RSHSmltdOpCapacity view union_all CONSUMPTION

Fields (8)

KeyField CDS FieldsUsed in Views
KEY ConsumingStartDate CalendarDate 1
KEY MaintenanceOrder MaintenanceOrder 1
KEY MaintenanceOrderOperation MaintenanceOrderOperation 1
KEY MaintenanceOrderSubOperation MaintenanceOrderSubOperation 1
KEY MaintSchedSimlnUUID MaintSchedSimlnUUID 1
NumberOfCapacities NumberOfCapacities 1
OperationControlKey OperationControlKey 1
WorkCenterInternalID WorkCenterInternalId 1
@AbapCatalog.sqlViewName: 'PRSHSIMOPINSEC'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.private: true
@VDM.viewType: #CONSUMPTION
@ClientHandling.algorithm: #SESSION_VARIABLE

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

Name:                       Read Simulated Operation duration and convert it to seconds
Specification:              This view reads the simulated operation duration and converts it to seconds.Planned work and duration
                            is calculaed if they are not maintained. Number of resources is defaulted to 1 if its not maintained.
                            This view also determines the start date and end date for the distribution of demand work from the
                            simulated start and end date. Few due operations might have been dispatched in a different session.
                            These Operations are also filtered in this view.
Requires:                   NA
Ensures:                    Duration and Number of capacities of simulated operations is read and converted into seconds
Owners:                     AN
Contributors:               CF
Unit Test required Y/N:     Yes
Additional comments

END OF CONTRACT***************************************************************************************************************
*/
define view P_RSHSmltdOpInSeconds
  as select distinct from I_RSHMaintSchedSmltdOp        as SimulatedOperations

    inner join            I_MaintOrderOperAndSubOper    as OperationDetails on  OperationDetails.MaintOrderRoutingNumber    = SimulatedOperations.MaintOrderRoutingNumber
                                                                            and OperationDetails.MaintOrderOperationCounter = SimulatedOperations.MaintOrderOperationCounter

    inner join            P_RSHMaintSchedSmltdDueStatus as OperationStatus  on  SimulatedOperations.MaintOrderRoutingNumber    = OperationStatus.MaintOrderRoutingNumber
                                                                            and SimulatedOperations.MaintOrderOperationCounter = OperationStatus.MaintOrderOperationCounter
{

  key     SimulatedOperations.MaintSchedSimlnUUID,
  key     OperationDetails.MaintenanceOrder,
  key     OperationDetails.MaintenanceOrderOperation,
  key     OperationDetails.MaintenanceOrderSubOperation,

          MaintPriority,
          MaintPriorityType,
          MaintPriorityColorCode,
          OrderType,
          SimulatedOperations.ActivityType,
          OperationDetails.OperationControlKey          as OperationControlKey,

          case SimulatedWorkCenterInternalID
            when '00000000'
              then WorkCenterInternalID
            else SimulatedWorkCenterInternalID
          end                                           as WorkCenterInternalID,

          case OperationStatus.ProcessingStatus
            when 20
                then SimulatedOperations.ProcessingStatus
            else OperationStatus.ProcessingStatus end   as ProcessingStatus,

          SimulatedOperations.MaintOrdOpSimulationStatus,
          SimulatedOperations.MaintOrdOpSimulatedStartDate,
          SimulatedOperations.MaintOrdOpSimulatedEndDate,

          // Determine from which date the operation is consuming (either from simulated start or simulation/week start)

          case when
            MaintOrdOpSimulatedStartDate = '00000000'
          then _MaintSchedSimulation.MaintSchedSimulationStartDate
          else MaintOrdOpSimulatedStartDate
            end                                         as ConsumingStartDate,

          // Determine until which date the operation is consuming (either from simulated end or simulation/week end)

          case when
            MaintOrdOpSimulatedEndDate = '99991231'
          then _MaintSchedSimulation.MaintSchedSimulationEndDate
          else MaintOrdOpSimulatedEndDate
            end                                         as ConsumingEndDate,

          SimulatedOperations.NumberOfResources         as NumberOfCapacities,

          //Determine the seconds between midnight and the planned start time

          case when
           SimulatedOperations.MaintOrdOpSimulatedStartTime = '240000'
          then 86400
          else
            cast( cast( substring(SimulatedOperations.MaintOrdOpSimulatedStartTime, 1, 2) as abap.numc(2) ) as abap.int4 ) * 3600
          + cast( cast( substring(SimulatedOperations.MaintOrdOpSimulatedStartTime, 3, 2) as abap.numc(2) ) as abap.int4 ) * 60
          + cast( cast( substring(SimulatedOperations.MaintOrdOpSimulatedStartTime, 5, 2) as abap.numc(2) ) as abap.int4 )
            end                                         as SimulatedStartTimeInSeconds,

          //Determine the seconds between midnight and the planned end time

          case when
            SimulatedOperations.MaintOrdOpSimulatedEndTime = '240000'
          then 86400
          else
             cast( cast( substring(SimulatedOperations.MaintOrdOpSimulatedEndTime, 1, 2) as abap.numc(2) ) as abap.int4 ) * 3600
           + cast( cast( substring(SimulatedOperations.MaintOrdOpSimulatedEndTime, 3, 2) as abap.numc(2) ) as abap.int4 ) * 60
           + cast( cast( substring(SimulatedOperations.MaintOrdOpSimulatedEndTime, 5, 2) as abap.numc(2) ) as abap.int4 )
             end                                        as SimulatedEndTimeInSeconds,

          // Determine from which time capacity is consumed by this operation

          case when
           SimulatedOperations.MaintOrdOpSimulatedStartTime = '240000'
          then 86400
          else
            cast( cast( substring(SimulatedOperations.MaintOrdOpSimulatedStartTime, 1, 2) as abap.numc(2) ) as abap.int4 ) * 3600
          + cast( cast( substring(SimulatedOperations.MaintOrdOpSimulatedStartTime, 3, 2) as abap.numc(2) ) as abap.int4 ) * 60
          + cast( cast( substring(SimulatedOperations.MaintOrdOpSimulatedStartTime, 5, 2) as abap.numc(2) ) as abap.int4 )
            end                                         as ConsumingStartTimeInSeconds,

          // Determine until which time capacity is consumed by this operation

          case when
            SimulatedOperations.MaintOrdOpSimulatedEndTime = '240000'
            or MaintOrdOpSimulatedEndDate = '00000000' //if no end date was scheduled, end time is initial but should be end of day for capacity calculations

          then 86400
          else
             cast( cast( substring(SimulatedOperations.MaintOrdOpSimulatedEndTime, 1, 2) as abap.numc(2) ) as abap.int4 ) * 3600
           + cast( cast( substring(SimulatedOperations.MaintOrdOpSimulatedEndTime, 3, 2) as abap.numc(2) ) as abap.int4 ) * 60
           + cast( cast( substring(SimulatedOperations.MaintOrdOpSimulatedEndTime, 5, 2) as abap.numc(2) ) as abap.int4 )
             end                                        as ConsumingEndTimeInSeconds,

          //Duration is calculated if it is not maintained

          case when ( ( SimulatedOperations.OperationDuration = 0 or SimulatedOperations.OperationDuration is null ) and SimulatedOperations.OperationPlannedWork > 0 )
          then cast ( SimulatedOperations.OperationPlannedWork as abap.fltp ) / cast ( SimulatedOperations.NumberOfResources as abap.fltp )
          else
           SimulatedOperations.OperationDuration end    as OperationDuration,

          SimulatedOperations.OperationDurationUnit     as OperationDurationUnit,

          //Planned work is calculated if it is not maintained


          case when SimulatedOperations.OperationPlannedWork  = 0 or SimulatedOperations.OperationPlannedWork is null
          then SimulatedOperations.OperationDuration * SimulatedOperations.NumberOfResources
          else
          SimulatedOperations.OperationPlannedWork  end as OperationPlannedWork,

          SimulatedOperations.OperationPlannedWorkUnit  as OperationPlannedWorkUnit,

          _MaintSchedSimulation.MaintSchedSimulationStartDate,
          _MaintSchedSimulation.MaintSchedSimulationEndDate
}
where
  (
          OperationStatus.ProcessingStatus = 20
    or(
          OperationStatus.ProcessingStatus = 30
      and MaintOrdOpSimulationStatus       = '30'
    )
  )
  and     UserIsAssignedToOpWrkCtr         = 'X'
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_MAINTORDEROPERANDSUBOPER",
"I_RSHMAINTSCHEDSIMULATION",
"I_RSHMAINTSCHEDSMLTDOP",
"P_RSHMAINTSCHEDSMLTDDUESTATUS"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/