P_SchedProdnOperationBasic

DDL: P_SCHEDPRODNOPERATIONBASIC SQL: PSCOPBA Type: view COMPOSITE

P_SchedProdnOperationBasic is a Composite CDS View in SAP S/4HANA. It reads from 4 data sources (I_SDMAreaOfResponsibility, I_SDMAreaOfResponsibility, P_ProcCapReqOpDurn, P_ProcCapReqOpDurn) and exposes 24 fields with key fields OrderID, CapacityRequirementItem, CapacityRqmtItemCapacity, OrderCategory, CapacityRequirementItem. It has 1 association to related views.

Data Sources (4)

SourceAliasJoin Type
I_SDMAreaOfResponsibility _arearespy inner
I_SDMAreaOfResponsibility _arearespy inner
P_ProcCapReqOpDurn ProcOpDurn left_outer
P_ProcCapReqOpDurn ProcOpDurn left_outer

Parameters (2)

NameTypeDefault
PStartDate sydatum
PEndDate sydatum

Associations (1)

CardinalityTargetAliasCondition
[1..1] I_StatusObjectStatus _StatusConfirmed CapRqmtItmCap.OrderObjectInternalID = _StatusConfirmed.StatusObject and _StatusConfirmed.StatusCode = 'I0009' and _StatusConfirmed.StatusIsActive = 'X'

Annotations (7)

NameValueLevelField
AbapCatalog.sqlViewName PSCOPBA view
AbapCatalog.compiler.compareFilter true view
ClientHandling.algorithm #SESSION_VARIABLE view
AbapCatalog.preserveKey true view
AccessControl.authorizationCheck #NOT_REQUIRED view
VDM.private true view
VDM.viewType #COMPOSITE view

Fields (24)

KeyFieldSource TableSource FieldDescription
KEY OrderID
KEY CapacityRequirementItem CapRqmtItmCap CapacityRequirementItem
KEY CapacityRqmtItemCapacity CapRqmtItmCap CapacityRqmtItemCapacity
KEY OrderCategory
WorkCenter
MainWorkCenter
Plant
MRPController
OperationLatestStartDate CapRqmtItmCap OperationLatestStartDate
OperationLatestEndDate CapRqmtItmCap OperationLatestEndDate
OriginallyScheduledStartDate CapRqmtItmCap OperationLatestStartDate
OriginallyScheduledEndDate CapRqmtItmCap OperationLatestEndDate
KEY CapacityRequirementItem CapRqmtItmCap CapacityRequirementItem
KEY CapacityRqmtItemCapacity CapRqmtItmCap CapacityRqmtItemCapacity
KEY OrderCategory
WorkCenter
MainWorkCenter
Plant
MRPController
OperationLatestStartDate CapRqmtItmCap OperationLatestStartDate
OperationLatestEndDate CapRqmtItmCap OperationLatestEndDate
OriginallyScheduledStartDate CapRqmtItmCap OperationLatestStartDate
OriginallyScheduledEndDate CapRqmtItmCap OperationLatestEndDate
MainProductionLine
@AbapCatalog.sqlViewName: 'PSCOPBA'
@AbapCatalog.compiler.compareFilter: true
@ClientHandling.algorithm: #SESSION_VARIABLE
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.private: true
@VDM.viewType: #COMPOSITE
define view P_SchedProdnOperationBasic
  with parameters
    PStartDate : sydatum,
    PEndDate   : sydatum

  as select distinct from(
                    I_CapacityRequirementItemCap as CapRqmtItmCap
      inner join    I_SDMAreaOfResponsibility    as _arearespy on  _arearespy.Plant         = Plant
                                                               and _arearespy.MRPController = MRPController
                                                               and _arearespy.UserID        = $session.user
  )
    left outer join P_ProcCapReqOpDurn           as ProcOpDurn on  CapRqmtItmCap.CapacityRequirement      = ProcOpDurn.CapacityRequirement
                                                               and CapRqmtItmCap.CapacityRequirementItem  = ProcOpDurn.SuperiorOperationInternalID
                                                               and CapRqmtItmCap.CapacityRqmtItemCapacity = ProcOpDurn.CapacityRqmtItemCapacity
                                                               and CapRqmtItmCap.OperationIsPhase         = '1'

  association [1..1] to I_StatusObjectStatus as _StatusConfirmed on  CapRqmtItmCap.OrderObjectInternalID = _StatusConfirmed.StatusObject
                                                                 and _StatusConfirmed.StatusCode         = 'I0009'
                                                                 and _StatusConfirmed.StatusIsActive     = 'X'
{

  key cast( CapRqmtItmCap.OrderID as pph_cfs_ordernumber )                  as OrderID,
  key CapRqmtItmCap.CapacityRequirementItem                                 as CapacityRequirementItem,
  key CapRqmtItmCap.CapacityRqmtItemCapacity,
  key cast(CapRqmtItmCap._Order.OrderCategory as pph_cfs_sch_ordercategory) as OrderCategory,
      case
            when _OrderOperation.OpDispatchedExecStartDate = '00000000'
              then cast('DALL' as pph_cfs_sch_status)
            else cast('DSPT' as pph_cfs_sch_status)
          end                                                               as OperationPlanningStatusCode,

      CapRqmtItmCap._WorkCenter.WorkCenter                                  as WorkCenter,
      CapRqmtItmCap._WorkCenter.WorkCenter                                  as MainWorkCenter,
      CapRqmtItmCap._WorkCenter.Plant                                       as Plant,
      cast( CapRqmtItmCap._Order.MRPController as dispo)                    as MRPController,

      case CapRqmtItmCap.RemainingCapReqOpSegSetupDurn
        when 0
          then 0
        else
          cast( unit_conversion(
                QUANTITY => CapRqmtItmCap.RemainingCapReqOpSegSetupDurn,
                SOURCE_UNIT => CapRqmtItmCap.CapacityRequirementUnit,
                TARGET_UNIT => cast( 'H' as abap.unit(3) ),
                ERROR_HANDLING => 'SET_TO_NULL' ) as cy_krueres )
      end                                                                   as RemCapReqOpSegSetupDurnInHours,
      case
        when CapRqmtItmCap.OperationIsPhase = '1'
          then
             case ProcOpDurn.TotRemCapReqOpSegProcgDurn
              when 0
                then 0
              else
                cast( unit_conversion(
                        QUANTITY => ProcOpDurn.TotRemCapReqOpSegProcgDurn,
                        SOURCE_UNIT => ProcOpDurn.CapacityRequirementUnit,
                        TARGET_UNIT => cast( 'H' as abap.unit(3) ),
                        ERROR_HANDLING => 'SET_TO_NULL' ) as cy_kbeares )
             end
        else
            case CapRqmtItmCap.RemainingCapReqOpSegProcgDurn
              when 0
                then 0
              else
                cast( unit_conversion(
                      QUANTITY => CapRqmtItmCap.RemainingCapReqOpSegProcgDurn,
                      SOURCE_UNIT => CapRqmtItmCap.CapacityRequirementUnit,
                      TARGET_UNIT => cast( 'H' as abap.unit(3) ),
                      ERROR_HANDLING => 'SET_TO_NULL' ) as cy_kbeares )
            end
       end                                                                  as RemCapReqOpSegProcgDurnInHours,
      case CapRqmtItmCap.RemainingCapReqOpSegTrdwnDurn
        when 0
          then 0
        else
          cast( unit_conversion(
                QUANTITY => CapRqmtItmCap.RemainingCapReqOpSegTrdwnDurn,
                SOURCE_UNIT => CapRqmtItmCap.CapacityRequirementUnit,
                TARGET_UNIT => cast( 'H' as abap.unit(3) ),
                ERROR_HANDLING => 'SET_TO_NULL' ) as cy_kabrres )
      end                                                                   as RemCapReqOpSegTrdwnDurnInHours,

      cast( case
       when _Order._OrderMainItem._ProductionVersion._BillOfOperationsType.BillOfOperationsApplication = 'R'
       then cast ('P' as plnaw)
       else
       cast (_Order._OrderMainItem._ProductionVersion._BillOfOperationsType.BillOfOperationsApplication as plnaw)
       end as plnaw preserving type )                                       as IndustryType,
      CapRqmtItmCap.OperationLatestStartDate                                as OperationLatestStartDate,
      CapRqmtItmCap.OperationLatestEndDate                                  as OperationLatestEndDate,
      CapRqmtItmCap.OperationLatestStartDate                                as OriginallyScheduledStartDate,
      CapRqmtItmCap.OperationLatestEndDate                                  as OriginallyScheduledEndDate,
      _Order._OrderMainItem._ProductionVersion.ProductionLine               as MainProductionLine
}
where
           CapRqmtItmCap._CapacityRequirement.CapacityRequirementOrigin =  '1'
  and      CapRqmtItmCap.CapacityInternalID                             =  CapRqmtItmCap._WorkCenter.CapacityInternalID
  and      CapRqmtItmCap._WorkCenter.AdvancedPlanningIsSupported        =  ''
  and      CapRqmtItmCap._Capacity.CapacityIsFinite                     =  'X'
  and(
    (
      (
           CapRqmtItmCap._Order.OrderCategory                           =  '10'
        or CapRqmtItmCap._Order.OrderCategory                           =  '40'
      )
      and  CapRqmtItmCap._WorkCenter.WorkCenter                         =  _Order._OrderMainItem._ProductionVersion.ProductionLine
      and  _OrderOperation.Sequence                                     =  '000000'
    )
    or     CapRqmtItmCap._Order.OrderCategory                           =  '30'
  )
  and      _StatusConfirmed.StatusCode                                  is null
  and(
           CapRqmtItmCap.OperationIsPhase                               <> '2'
  )
  and(
           CapRqmtItmCap.OperationLatestStartDate                       <= $parameters.PEndDate
    and    CapRqmtItmCap.OperationLatestEndDate                         >= $parameters.PStartDate
  )
  and      CapRqmtItmCap._OrderOperation.Sequence                       =  '000000'

union all select distinct from I_CapacityRequirementItemCap as CapRqmtItmCap
  left outer join              P_ProcCapReqOpDurn           as ProcOpDurn on  CapRqmtItmCap.CapacityRequirement      = ProcOpDurn.CapacityRequirement
                                                                          and CapRqmtItmCap.CapacityRequirementItem  = ProcOpDurn.SuperiorOperationInternalID
                                                                          and CapRqmtItmCap.CapacityRqmtItemCapacity = ProcOpDurn.CapacityRqmtItemCapacity

  inner join                   I_SDMAreaOfResponsibility    as _arearespy on  _arearespy.Plant         = Plant
                                                                          and _arearespy.MRPController = MRPController
                                                                          and _arearespy.UserID        = $session.user

association [1..1] to I_StatusObjectStatus as _StatusConfirmed on  CapRqmtItmCap.OrderObjectInternalID = _StatusConfirmed.StatusObject
                                                               and _StatusConfirmed.StatusCode         = 'I0009'
                                                               and _StatusConfirmed.StatusIsActive     = 'X'
{

  key cast ( CapRqmtItmCap.PlannedOrder as pph_cfs_ordernumber)                           as OrderID,
  key CapRqmtItmCap.CapacityRequirementItem                                               as CapacityRequirementItem,
  key CapRqmtItmCap.CapacityRqmtItemCapacity,
  key cast(CapRqmtItmCap._PlannedOrder.PlannedOrderCategory as pph_cfs_sch_ordercategory) as OrderCategory,
      case
            when CapRqmtItmCap._OrderStatusObjectStatus.StatusCode = 'I0117' and CapRqmtItmCap._OrderStatusObjectStatus.StatusIsInactive = ''
              then cast('DSPT' as pph_cfs_sch_status)
            else cast('DALL' as pph_cfs_sch_status)
          end                                                                             as OperationPlanningStatusCode,
      CapRqmtItmCap._WorkCenter.WorkCenter                                                as WorkCenter,
      CapRqmtItmCap._WorkCenter.WorkCenter                                                as MainWorkCenter,
      CapRqmtItmCap._WorkCenter.Plant                                                     as Plant,
      cast( CapRqmtItmCap._Order.MRPController as dispo)                                  as MRPController,

      case CapRqmtItmCap.RemainingCapReqOpSegSetupDurn
              when 0
                then 0
              else
                cast( unit_conversion(
                      QUANTITY => CapRqmtItmCap.RemainingCapReqOpSegSetupDurn,
                      SOURCE_UNIT => CapRqmtItmCap.CapacityRequirementUnit,
                      TARGET_UNIT => cast( 'H' as abap.unit(3) ),
                      ERROR_HANDLING => 'SET_TO_NULL' ) as cy_krueres )
      end                                                                                 as RemCapReqOpSegSetupDurnInHours,
      case
        when CapRqmtItmCap.OperationIsPhase = '1'
          then case ProcOpDurn.TotRemCapReqOpSegProcgDurn
                  when 0
                    then 0
                  else
                    cast( unit_conversion(
                          QUANTITY => ProcOpDurn.TotRemCapReqOpSegProcgDurn,
                          SOURCE_UNIT => ProcOpDurn.CapacityRequirementUnit,
                          TARGET_UNIT => cast( 'H' as abap.unit(3) ),
                          ERROR_HANDLING => 'SET_TO_NULL' ) as cy_kbeares )
               end
        else
            case CapRqmtItmCap.RemainingCapReqOpSegProcgDurn
              when 0
                then 0
              else
                cast( unit_conversion(
                      QUANTITY => CapRqmtItmCap.RemainingCapReqOpSegProcgDurn,
                      SOURCE_UNIT => CapRqmtItmCap.CapacityRequirementUnit,
                      TARGET_UNIT => cast( 'H' as abap.unit(3) ),
                      ERROR_HANDLING => 'SET_TO_NULL' ) as cy_kbeares )
            end
       end                                                                                as RemCapReqOpSegProcgDurnInHours,
      case CapRqmtItmCap.RemainingCapReqOpSegTrdwnDurn
              when 0
                then 0
              else
                cast( unit_conversion(
                      QUANTITY => CapRqmtItmCap.RemainingCapReqOpSegTrdwnDurn,
                      SOURCE_UNIT => CapRqmtItmCap.CapacityRequirementUnit,
                      TARGET_UNIT => cast( 'H' as abap.unit(3) ),
                      ERROR_HANDLING => 'SET_TO_NULL' ) as cy_kabrres )
      end                                                                                 as RemCapReqOpSegTrdwnDurnInHours,

      cast( case
      when CapRqmtItmCap._BillOfOperationsType.BillOfOperationsApplication = 'R'
      then cast ('P' as plnaw)
      else
      cast (CapRqmtItmCap._BillOfOperationsType.BillOfOperationsApplication as plnaw)
      end as plnaw preserving type )                                                      as IndustryType,
      CapRqmtItmCap.OperationLatestStartDate                                              as OperationLatestStartDate,
      CapRqmtItmCap.OperationLatestEndDate                                                as OperationLatestEndDate,
      CapRqmtItmCap.OperationLatestStartDate                                              as OriginallyScheduledStartDate,
      CapRqmtItmCap.OperationLatestEndDate                                                as OriginallyScheduledEndDate,
      _Order._OrderMainItem._ProductionVersion.ProductionLine                             as MainProductionLine

}
where
        CapRqmtItmCap._CapacityRequirement.CapacityRequirementOrigin =  '2'
  and   CapRqmtItmCap._PlannedOrder.PlannedOrderCategory             =  '1'
  and   CapRqmtItmCap.CapacityInternalID                             =  CapRqmtItmCap._WorkCenter.CapacityInternalID
  and   CapRqmtItmCap._WorkCenter.AdvancedPlanningIsSupported        =  ''
  and   _StatusConfirmed.StatusCode                                  is null
  and   CapRqmtItmCap._Capacity.CapacityIsFinite                     =  'X'
  and(
        CapRqmtItmCap.OperationIsPhase                               <> '2'
  )
  and(
        CapRqmtItmCap.OperationLatestStartDate                       <= $parameters.PEndDate
    and CapRqmtItmCap.OperationLatestEndDate                         >= $parameters.PStartDate
  )
  and   CapRqmtItmCap._WorkCenter.WorkCenter                         =  CapRqmtItmCap._PlannedOrder._ProductionVersion.ProductionLine
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_BILLOFOPERATIONSTYPE",
"I_CAPACITY",
"I_CAPACITYREQUIREMENT",
"I_CAPACITYREQUIREMENTITEMCAP",
"I_LOGISTICSORDER",
"I_ORDERITEM",
"I_ORDEROPERATION",
"I_PLANNEDORDER",
"I_PRODUCTIONVERSION",
"I_SDMAREAOFRESPONSIBILITY",
"I_STATUSOBJECTSTATUS",
"I_WORKCENTER",
"P_PROCCAPREQOPDURN"
],
"ASSOCIATED":
[
"I_STATUSOBJECTSTATUS"
],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/