P_RSHOperationsForKPI

DDL: P_RSHOPERATIONSFORKPI SQL: PRSHOPERATIONKPI Type: view CONSUMPTION

Operations and Sub Operations for overview page

P_RSHOperationsForKPI is a Consumption CDS View that provides data about "Operations and Sub Operations for overview page" in SAP S/4HANA. It reads from 7 data sources and exposes 19 fields with key fields MaintenanceOrder, MaintenanceOrderOperation, MaintenanceOrderSubOperation.

Data Sources (7)

SourceAliasJoin Type
I_StatusObjectStatusBasic excl_status left_outer
I_MaintOrderOperPlanningValues I_MaintOrderOperPlanningValues inner
I_StatusObjectStatusBasic incl_status inner
I_MaintOrderOperAndSubOper iop from
I_MaintenanceOrder iorder inner
I_OperationControlProfile operation_controlprofile inner
I_RSHAssignedWorkCenters user_var inner

Parameters (2)

NameTypeDefault
P_StartDate datum
P_EndDate datum

Annotations (7)

NameValueLevelField
AbapCatalog.sqlViewName PRSHOPERATIONKPI view
AbapCatalog.compiler.compareFilter true view
AccessControl.authorizationCheck #NOT_REQUIRED view
VDM.private true view
VDM.viewType #CONSUMPTION view
ClientHandling.algorithm #SESSION_VARIABLE view
EndUserText.label Operations and Sub Operations for overview page view

Fields (19)

KeyFieldSource TableSource FieldDescription
KEY MaintenanceOrder I_MaintOrderOperAndSubOper MaintenanceOrder
KEY MaintenanceOrderOperation I_MaintOrderOperAndSubOper MaintenanceOrderOperation
KEY MaintenanceOrderSubOperation I_MaintOrderOperAndSubOper MaintenanceOrderSubOperation
MaintPriority I_MaintenanceOrder MaintPriority
MaintenanceActivityType I_MaintenanceOrder MaintenanceActivityType
MaintenanceOrderType I_MaintenanceOrder MaintenanceOrderType
WorkCenterInternalID I_MaintOrderOperAndSubOper OperationWorkCenterInternalID
WorkCenterTypeCode I_MaintOrderOperAndSubOper OperationWorkCenterTypeCode
Plant I_MaintOrderOperAndSubOper Plant
ControllingArea
MaintenancePlannerGroup I_MaintenanceOrder MaintenancePlannerGroup
MaintenancePlant
ResponsibleCostCenter
AuthorizationGroup
FunctionalLocation
FunctionalLocationLabelName
Equipment I_MaintenanceOrder Equipment
MaintenanceRevision I_MaintenanceOrder MaintenanceRevision
OperationControlKey I_MaintOrderOperAndSubOper OperationControlKey
@AbapCatalog.sqlViewName: 'PRSHOPERATIONKPI'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.private: true
@VDM.viewType: #CONSUMPTION
@ClientHandling.algorithm: #SESSION_VARIABLE
@EndUserText.label: 'Operations and Sub Operations for overview page'

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

Name:                       Operations and Suboperations from relevant work center and timeframe
Specification:              This view will retrieve the operations and sub operations from relevant work centers and timeframe.
                            Operations with status Confirmed and Deleted are excluded. The processing status is determined.
Requires:                   Work Center assignment in I_RSHAssignedWorkCenters.
Ensures:                    Operations and sub operations from relevant work centers, timeframe are returned
Owners:                     CK
Contributors:               SY
Abap Unit:                  Yes

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


define view P_RSHOperationsForKPI
  with parameters
    P_StartDate : datum,
    P_EndDate   : datum
  as select from    I_MaintOrderOperAndSubOper as iop

    inner join      I_MaintenanceOrder         as iorder                   on iorder.MaintenanceOrder = iop.MaintenanceOrder

    inner join      I_MaintOrderOperPlanningValues                         on  iop.MaintOrderRoutingNumber    = I_MaintOrderOperPlanningValues.MaintOrderRoutingNumber
                                                                           and iop.MaintOrderOperationCounter = I_MaintOrderOperPlanningValues.MaintOrderOperationCounter

    inner join      I_RSHAssignedWorkCenters   as user_var                 on  iop.OperationWorkCenterInternalID = user_var.WorkCenterInternalID
                                                                           and iop.OperationWorkCenterTypeCode   = user_var.WorkCenterTypeCode

  //Filter out the operations with control key which is not relevant for scheduling

    inner join      I_OperationControlProfile  as operation_controlprofile on  operation_controlprofile.OperationControlProfile = iop.OperationControlKey
                                                                           and operation_controlprofile.OperationIsScheduled    = 'X'

  --- Filter Due, Dispatched and Partially Confirmed Operation Status
    inner join      I_StatusObjectStatusBasic  as incl_status              on  incl_status.StatusObject     = iop.MaintOrderOperationInternalID
                                                                           and incl_status.StatusIsInactive = ''
                                                                           and (
                                                                              incl_status.StatusCode        = 'I0010' //PART. CONFIRMED

                                                                              or incl_status.StatusCode     = 'I0117' //DISPATCHED

                                                                              or incl_status.StatusCode     = 'I0002' //RELEASED

                                                                              or incl_status.StatusCode     = 'I0001' //CREATED

                                                                            )

  --- Filter Out Operation Status: Delete or Confirmed Status
    left outer join I_StatusObjectStatusBasic  as excl_status              on  excl_status.StatusObject     = iop.MaintOrderOperationInternalID
                                                                           and excl_status.StatusIsInactive = ''
                                                                           and (
                                                                              excl_status.StatusCode        = 'I0013' //DELETED

                                                                              or excl_status.StatusCode     = 'I0045' //TECHN. COMPLETED

                                                                              or excl_status.StatusCode     = 'I0009' //CONFIRMED

                                                                              or excl_status.StatusCode     = 'I0043' //LOCKED

                                                                              or excl_status.StatusCode     = 'I0046' //CLOSED  (Business Closed)

                                                                            )

  association [1..1] to I_SchedulingType on iorder.BasicSchedulingType = I_SchedulingType.SchedulingType

{
  key   iop.MaintenanceOrder,
  key   iop.MaintenanceOrderOperation,
  key   iop.MaintenanceOrderSubOperation,


        iorder.MaintPriority,
        iorder.MaintenanceActivityType,
        iorder.MaintenanceOrderType,
        iop.OperationWorkCenterInternalID as WorkCenterInternalID,
        iop.OperationWorkCenterTypeCode   as WorkCenterTypeCode,
        iop.Plant                         as Plant,

        max( case incl_status.StatusCode
            when 'I0010' then 40  //In Process

            when 'I0117' then 30  //Dispatched

            when 'I0002' then 20  //Due

            when 'I0001' then 20  //Due

            end )                         as ProcessingStatus,

        iorder._Order.ControllingArea,
        iorder.MaintenancePlannerGroup,
        iorder._LocationAccountAssignment.MaintenancePlant,
        iorder._Order.ResponsibleCostCenter,
        iorder._Equipment.AuthorizationGroup,
        iorder._LocationAccountAssignment.FunctionalLocation,
        iorder._LocationAccountAssignment._FunctionalLocation._FunctionalLocationLabel.FunctionalLocationLabelName,
        iorder.Equipment,
        iorder.MaintenanceRevision,
        iop.OperationControlKey

}

where
          excl_status.StatusObject                                is null
  and

  // only look at operations that are in the current timeframe either with earliest or latest dates depending on backward scheduling or not.


  (
    (
          I_MaintOrderOperPlanningValues.OpErlstSchedldExecEndDte <  $parameters.P_EndDate
      and I_MaintOrderOperPlanningValues.OpErlstSchedldExecEndDte >= $parameters.P_StartDate
      and I_SchedulingType.SchedulingIsPerformedBackward          = ''
    )
    or(
          I_MaintOrderOperPlanningValues.OpErlstSchedldExecEndDte <  $parameters.P_EndDate
      and I_MaintOrderOperPlanningValues.OpLtstSchedldExecEndDte  >= $parameters.P_StartDate
      and I_SchedulingType.SchedulingIsPerformedBackward          = 'X'
    )
  )
  
/*  
  (
    (
          iop.OpErlstSchedldExecStrtDte <= $parameters.P_EndDate
      and iop.OpErlstSchedldExecEndDte >= $parameters.P_StartDate
      and I_SchedulingType.SchedulingIsPerformedBackward = ''
    )
    or(
          iop.OpLtstSchedldExecStrtDte <= $parameters.P_EndDate
      and iop.OpLtstSchedldExecEndDte  >= $parameters.P_StartDate
      and I_SchedulingType.SchedulingIsPerformedBackward = 'X'
    )
  )
*/ 

group by
  iop.MaintenanceOrder,
  iop.MaintenanceOrderOperation,
  iop.MaintenanceOrderSubOperation,
  iorder.MaintPriority,
  iorder.MaintenanceActivityType,
  iorder.MaintenanceOrderType,
  iop.OperationWorkCenterInternalID,
  iop.OperationWorkCenterTypeCode,
  iop.Plant,
  I_MaintOrderOperPlanningValues.OpErlstSchedldExecStrtDte,
  I_MaintOrderOperPlanningValues.OpErlstSchedldExecEndDte,
  I_MaintOrderOperPlanningValues.OpLtstSchedldExecStrtDte,
  I_MaintOrderOperPlanningValues.OpLtstSchedldExecEndDte,
  I_SchedulingType.SchedulingIsPerformedBackward,
  iorder._Order.ControllingArea,
  iorder.MaintenancePlannerGroup,
  iorder._LocationAccountAssignment.MaintenancePlant,
  iorder._Order.ResponsibleCostCenter,
  iorder._Equipment.AuthorizationGroup,
  iorder._LocationAccountAssignment.FunctionalLocation,
  iorder._LocationAccountAssignment._FunctionalLocation._FunctionalLocationLabel.FunctionalLocationLabelName,
  iorder.Equipment,
  iorder.MaintenanceRevision,
  iop.OperationControlKey
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_EQUIPMENT",
"I_FUNCTIONALLOCATION",
"I_FUNCTIONALLOCATIONLABEL",
"I_LOCATIONACCOUNTASSIGNMENT",
"I_LOGISTICSORDER",
"I_MAINTENANCEORDER",
"I_MAINTORDEROPERANDSUBOPER",
"I_MAINTORDEROPERPLANNINGVALUES",
"I_OPERATIONCONTROLPROFILE",
"I_RSHASSIGNEDWORKCENTERS",
"I_SCHEDULINGTYPE",
"I_STATUSOBJECTSTATUSBASIC"
],
"ASSOCIATED":
[
"I_SCHEDULINGTYPE"
],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/