I_MaintOrderHasOpenMainWork

DDL: I_MAINTORDERHASOPENMAINWORK SQL: IPMORDERHASWORK Type: view COMPOSITE

I_MaintOrderHasOpenMainWork

I_MaintOrderHasOpenMainWork is a Composite CDS View that provides data about "I_MaintOrderHasOpenMainWork" in SAP S/4HANA. It reads from 2 data sources (I_MaintenanceOrderOperation, I_MaintOperationExecStageCode) and exposes 2 fields with key field MaintenanceOrder.

Data Sources (2)

SourceAliasJoin Type
I_MaintenanceOrderOperation _MaintenanceOrderOperation from
I_MaintOperationExecStageCode _MaintOperationExecStageCode inner

Annotations (10)

NameValueLevelField
VDM.viewType #COMPOSITE view
AbapCatalog.sqlViewName IPMORDERHASWORK view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
AccessControl.authorizationCheck #NOT_REQUIRED view
EndUserText.label I_MaintOrderHasOpenMainWork view
ClientHandling.algorithm #SESSION_VARIABLE view
ObjectModel.usageType.dataClass #ORGANIZATIONAL view
ObjectModel.usageType.serviceQuality #X view
ObjectModel.usageType.sizeCategory #XL view

Fields (2)

KeyFieldSource TableSource FieldDescription
KEY MaintenanceOrder I_MaintenanceOrderOperation MaintenanceOrder
_MaintenanceOrder _MaintenanceOrder
@VDM.viewType: #COMPOSITE
@AbapCatalog.sqlViewName: 'IPMORDERHASWORK'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'I_MaintOrderHasOpenMainWork'

@ClientHandling.algorithm: #SESSION_VARIABLE
@ObjectModel.usageType.dataClass: #ORGANIZATIONAL
@ObjectModel.usageType.serviceQuality: #X
@ObjectModel.usageType.sizeCategory: #XL

define view I_MaintOrderHasOpenMainWork
 as select from           I_MaintenanceOrderOperation   as _MaintenanceOrderOperation

inner join             I_MaintOperationExecStageCode as _MaintOperationExecStageCode on  _MaintenanceOrderOperation.MaintOperationExecStageCode = _MaintOperationExecStageCode.MaintOperationExecStageCode
                                                                                         and _MaintOperationExecStageCode.MaintOpExecStageGroupCode = 'MAIN'

    left outer to one join I_StatusObjectStatusBasic     as _StatusObjectStatusBasic_del on  _MaintenanceOrderOperation.MaintOrderOperationInternalID = _StatusObjectStatusBasic_del.StatusObject
                                                                                         and _StatusObjectStatusBasic_del.StatusCode                  = 'I0013' //Deleted


    left outer to one join I_StatusObjectStatusBasic     as _StatusObjectStatusPCNF      on  _MaintenanceOrderOperation.MaintOrderOperationInternalID = _StatusObjectStatusPCNF.StatusObject
                                                                                         and _StatusObjectStatusPCNF.StatusCode                       = 'I0010' //Partially Confirmed

                                                                                         and _StatusObjectStatusPCNF.StatusIsInactive                 = ''
                                                                                         
                                                                                         
    left outer to one join I_StatusObjectStatusBasic     as _StatusObjectStatusPWF       on  _MaintenanceOrderOperation.MaintOrderOperationInternalID = _StatusObjectStatusPWF.StatusObject
                                                                                         and _StatusObjectStatusPWF.StatusCode                       = 'IEAMP' //Planned work Finished

                                                                                         and _StatusObjectStatusPWF.StatusIsInactive                 = ''                                                                                                                                                                                                                                                           
                                                                                                                                                                              
    left outer to one join I_OperationControlProfile     as _OperationControlProfile     on  _MaintenanceOrderOperation.OperationControlKey            = _OperationControlProfile.OperationControlProfile
   
    left outer to one join I_MaintenanceOrderComponent_2 as _MaintenanceOrderComponent   on  _MaintenanceOrderComponent.MaintenanceOrder               = _MaintenanceOrderOperation.MaintenanceOrder
                                                                                         and  _MaintenanceOrderComponent.MaintenanceOrderOperation     = _MaintenanceOrderOperation.MaintenanceOrderOperation
                                                                                         and  _MaintenanceOrderComponent.ProductTypeCode               = '2'    
                                                                                         and _MaintenanceOrderComponent.IsDeleted                      = ''     //lean service

                                                                                                                                                                           
{
  key _MaintenanceOrderOperation.MaintenanceOrder,
  
    max(
         case
         //If confirmation is required and PWF is set  -> NO ? YES

         when ( _OperationControlProfile.ConfirmationIsRequired = 'X' and _StatusObjectStatusPWF.StatusIsInactive is null) then 'X' //--

         //If confirmation is optional and there is srv and PWF -> NO ? YES

         when ( _OperationControlProfile.ConfirmationIsOptional = 'X' and _MaintenanceOrderComponent.MaintenanceOrderComponent is not null and _StatusObjectStatusPWF.StatusIsInactive is null) then 'X' //--

         //IF confirmation is optional and external processing = ‘+ ‘ and PWF -> NO ? YES

         when ( _OperationControlProfile.ConfirmationIsOptional = 'X' and _OperationControlProfile.OperationExternalProcessing = '+'  and _StatusObjectStatusPWF.StatusIsInactive is null) then 'X' //--

         //IF confirmation is optional there is no srv there is no external data and it IS PCNF -> YES ? NO

         when ( _OperationControlProfile.ConfirmationIsOptional = 'X' and _MaintenanceOrderComponent.MaintenanceOrderComponent is null
                 and _OperationControlProfile.OperationExternalProcessing != '+' and _StatusObjectStatusPCNF.StatusIsInactive is not null) then 'X' //--  ??? 

         //If confirmation is not possible and there is srv and PWF -> NO ? YES

         when ( _OperationControlProfile.ConfirmationIsNotPossible = 'X' and _MaintenanceOrderComponent.MaintenanceOrderComponent is not null 
                and _StatusObjectStatusPWF.StatusIsInactive is null) then 'X' //--

         //If confirmation is not possible and there is external data and PWF -> NO ? YES

         when ( _OperationControlProfile.ConfirmationIsNotPossible = 'X' 
                and _StatusObjectStatusPWF.StatusIsInactive is null) then '' //--

         //IF confirmation is not possible there is no srv there is no external data => NO

         when ( _OperationControlProfile.ConfirmationIsNotPossible = 'X' and _MaintenanceOrderComponent.MaintenanceOrderComponent is null 
                and _OperationControlProfile.OperationExternalProcessing != '+' ) then '' //--

         //Default

          when _StatusObjectStatusPWF.StatusIsInactive is null then ''
          else ''
        end
       ) as MaintOrdHasOpenMainWork,

      _MaintenanceOrder
}
where
  _StatusObjectStatusBasic_del.StatusIsInactive is null
group by
  _MaintenanceOrderOperation.MaintenanceOrder