P_RSHDueOperForKPIDetails

DDL: P_RSHDUEOPERFORKPIDETAILS SQL: PRSHDUEOPKPIDET Type: view CONSUMPTION Package: RSH_CDS_ORD

Due Order Operation KPI Details

P_RSHDueOperForKPIDetails is a Consumption CDS View that provides data about "Due Order Operation KPI Details" in SAP S/4HANA. It reads from 7 data sources and exposes 9 fields with key fields MaintOrderRoutingNumber, OrderOperationInternalID. Part of development package RSH_CDS_ORD.

Data Sources (7)

SourceAliasJoin Type
I_RSHAssignedWorkCenters _AssignedWorkCenter inner
I_RSHOrder _MaintOrder from
I_MaintOrderOperPlanningValues _MaintOrderOpPlanValue inner
I_RSHOperationStatusObject _OperationStatusObj inner
I_OperationControlProfile _OperControlProfile inner
I_OrderOperationBasic _OrderOpBasic inner
I_SchedulingType _SchedulingType inner

Parameters (2)

NameTypeDefault
P_StartDate datum
P_EndDate datum

Annotations (8)

NameValueLevelField
AbapCatalog.sqlViewName PRSHDUEOPKPIDET view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
AccessControl.authorizationCheck #NOT_REQUIRED view
VDM.private true view
VDM.viewType #CONSUMPTION view
ClientHandling.algorithm #SESSION_VARIABLE view
EndUserText.label Due Order Operation KPI Details view

Fields (9)

KeyFieldSource TableSource FieldDescription
KEY MaintOrderRoutingNumber I_RSHOrder MaintOrderRoutingNumber
KEY OrderOperationInternalID I_OrderOperationBasic OrderOperationInternalID
MaintenanceOrder I_RSHOrder MaintenanceOrder
WorkCenterInternalID I_OrderOperationBasic WorkCenterInternalID
Plant I_OrderOperationBasic Plant
OperationControlProfile I_OrderOperationBasic OperationControlProfile
Equipment I_RSHOrder Equipment
MaintObjectLocAcctAssgmtNmbr I_RSHOrder MaintObjectLocAcctAssgmtNmbr
OperationPersonResponsible I_OrderOperationBasic OperationPersonResponsible
@AbapCatalog.sqlViewName: 'PRSHDUEOPKPIDET'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey:true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.private: true
@VDM.viewType: #CONSUMPTION
@ClientHandling.algorithm: #SESSION_VARIABLE
@EndUserText.label: 'Due Order Operation KPI Details'


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

Name:                       Operations from relevant work center for the supplied time frame
Specification:              This view will retrieve the operations from relevant work centers and timeframe.
                            Operations with all status are determined. The processing status is determined as well
Requires:                   Work Center assignment in I_RSHAssignedWorkCenters.
Ensures:                    Operations are fetched for one additional day as Start Date and End Date is in usertimezone and
                            all the operations might not be included as operation dates are in system timezone.
                            These are filtered correctly in the higher views where operation dates are convered to user timezone
                            (This view is used in Due Order KPI Cards logic of OVP)
Owners:                     PP
Contributors:               DJ
Abap Unit:                  Yes

END OF CONTRACT***************************************************************************************************************
*/
define view P_RSHDueOperForKPIDetails
  with parameters
    P_StartDate : datum,
    P_EndDate   : datum
  as select from I_RSHOrder                     as _MaintOrder
    inner join   I_OrderOperationBasic          as _OrderOpBasic          on _MaintOrder.MaintOrderRoutingNumber = _OrderOpBasic.OrderInternalID
    inner join   I_MaintOrderOperPlanningValues as _MaintOrderOpPlanValue on  _OrderOpBasic.OrderInternalID          = _MaintOrderOpPlanValue.MaintOrderRoutingNumber
                                                                          and _OrderOpBasic.OrderOperationInternalID = _MaintOrderOpPlanValue.MaintOrderOperationCounter
  // Work Center

    inner join   I_RSHAssignedWorkCenters       as _AssignedWorkCenter    on  _OrderOpBasic.WorkCenterInternalID = _AssignedWorkCenter.WorkCenterInternalID
                                                                          and _OrderOpBasic.WorkCenterTypeCode   = _AssignedWorkCenter.WorkCenterTypeCode
  // Operation Control Profile

    inner join   I_OperationControlProfile      as _OperControlProfile    on  _OrderOpBasic.OperationControlProfile    = _OperControlProfile.OperationControlProfile
                                                                          and _OperControlProfile.OperationIsScheduled = 'X'
  // Operation Status

    inner join   I_RSHOperationStatusObject     as _OperationStatusObj    on _OrderOpBasic.ObjectInternalID = _OperationStatusObj.StatusObject
  // Scheduling Type

    inner join   I_SchedulingType               as _SchedulingType        on _MaintOrder.BasicSchedulingType = _SchedulingType.SchedulingType
{

  key _MaintOrder.MaintOrderRoutingNumber      as MaintOrderRoutingNumber,
  key _OrderOpBasic.OrderOperationInternalID   as OrderOperationInternalID,
      _MaintOrder.MaintenanceOrder             as MaintenanceOrder,
      _OrderOpBasic.WorkCenterInternalID       as WorkCenterInternalID,
      _OrderOpBasic.Plant                      as Plant,
      _OrderOpBasic.OperationControlProfile    as OperationControlProfile,
      _MaintOrder.Equipment                    as Equipment,
      _MaintOrder.MaintObjectLocAcctAssgmtNmbr as MaintObjectLocAcctAssgmtNmbr,

        // --- If scheduling backward is not on, then use earliest date otherwise latest for the remaining fields ---

        case when _SchedulingType.SchedulingIsPerformedBackward = ''
                 then _MaintOrderOpPlanValue.OpErlstSchedldExecStrtDte
                 else _MaintOrderOpPlanValue.OpLtstSchedldExecStrtDte end as PlannedStartDate,

        case when _SchedulingType.SchedulingIsPerformedBackward = ''
                 then _MaintOrderOpPlanValue.OpErlstSchedldExecStrtTme
                 else _MaintOrderOpPlanValue.OpLtstSchedldExecStrtTme end as PlannedStartTime,

        case when _SchedulingType.SchedulingIsPerformedBackward = ''
                then _MaintOrderOpPlanValue.OpErlstSchedldExecEndDte
                else _MaintOrderOpPlanValue.OpLtstSchedldExecEndDte end   as PlannedEndDate,

        case when _SchedulingType.SchedulingIsPerformedBackward = ''
               then _MaintOrderOpPlanValue.OpErlstSchedldExecEndTme
               else _MaintOrderOpPlanValue.OpLtstSchedldExecEndTme end    as PlannedEndTime,

      max( case _OperationStatusObj.StatusCode
               when 'I0010' then 40 --PART. CONFIRMED
               when 'I0117' then 30 --DISPATCHED
               when 'I0002' then 20 --RELEASED
               when 'I0001' then 20 --CREATED
               when 'I0045' then 50 --CONFIRMED
               when 'I0009' then 50 --CONFIRMED
               when 'I0046' then 50 --Business Closed
               when 'I0013' then 60 --Deleted
               when 'I0043' then 70 --Locked
           end )                               as ProcessingStatus,

      _OrderOpBasic.OperationPersonResponsible as OperationPersonResponsible
}

where
  (
    (
          _MaintOrderOpPlanValue.OpErlstSchedldExecStrtDte <= dats_add_days( $parameters.P_EndDate, 1, 'FAIL' )
      and _MaintOrderOpPlanValue.OpErlstSchedldExecEndDte  >= dats_add_days( $parameters.P_StartDate, -1, 'FAIL' )
      and _SchedulingType.SchedulingIsPerformedBackward    =  ''
    )
    or(
          _MaintOrderOpPlanValue.OpLtstSchedldExecStrtDte  <= dats_add_days($parameters.P_EndDate, 1, 'FAIL' )
      and _MaintOrderOpPlanValue.OpLtstSchedldExecEndDte   >= dats_add_days($parameters.P_StartDate, -1, 'FAIL' )
      and _SchedulingType.SchedulingIsPerformedBackward    =  'X'
    )
  )

group by

  _MaintOrder.MaintenanceOrder,
  _MaintOrder.MaintOrderRoutingNumber,
  _OrderOpBasic.OrderOperationInternalID,
  _OrderOpBasic.WorkCenterInternalID,
  _OrderOpBasic.Plant,
  _OrderOpBasic.OperationControlProfile,
  _MaintOrder.Equipment,
  _MaintOrder.MaintObjectLocAcctAssgmtNmbr,
  _MaintOrderOpPlanValue.OpErlstSchedldExecStrtDte,
  _MaintOrderOpPlanValue.OpErlstSchedldExecStrtTme,
  _MaintOrderOpPlanValue.OpErlstSchedldExecEndDte,
  _MaintOrderOpPlanValue.OpErlstSchedldExecEndTme,
  _MaintOrderOpPlanValue.OpLtstSchedldExecStrtDte,
  _MaintOrderOpPlanValue.OpLtstSchedldExecStrtTme,
  _MaintOrderOpPlanValue.OpLtstSchedldExecEndDte,
  _MaintOrderOpPlanValue.OpLtstSchedldExecEndTme,
  _SchedulingType.SchedulingIsPerformedBackward,
  _OrderOpBasic.OperationPersonResponsible