P_Sched_Past_Operations is a Composite CDS View that provides data about "Past orders for Deallocate action" in SAP S/4HANA. It reads from 4 data sources (I_LogisticsOrder, I_SchedCapacityRqmtItemCap, I_SchedCapacityRqmtItemCap, I_PlannedOrder) and exposes 19 fields with key fields orderid, CapacityRequirementItem, CapacityRqmtItemCapacity, CapacityRequirement, CapacityRequirementItem.
@AbapCatalog.sqlViewName: 'PSCHEDPASTOPERS'
@AbapCatalog.compiler.compareFilter: true@AbapCatalog.preserveKey: true@AccessControl.authorizationCheck: #NOT_REQUIRED@EndUserText.label: 'Past orders for Deallocate action'
@VDM.private: true@VDM.viewType: #COMPOSITE@ClientHandling.algorithm: #SESSION_VARIABLE/*---This View cannot be used for anywhere except the getting past operations fot Deallocate action
this logic might be changed at anytime it should not it should not attach to anyother CDS views---*/defineview P_Sched_Past_Operations
asselectfrom I_LogisticsOrder as _Order
innerjoin I_SchedCapacityRqmtItemCap as CapRqmtItmCap on _Order.CapacityRequirement = CapRqmtItmCap.CapacityRequirement
leftouter to one join I_OrderOperation as _OrderOperation on CapRqmtItmCap.OrderInternalID = _OrderOperation.OrderInternalID
and CapRqmtItmCap.OrderOperationInternalID = _OrderOperation.OrderOperationInternalID
and _Order.Plant = _OrderOperation.Plant
and _Order.CapacityRequirement = _OrderOperation.CapacityRequirement
// leftouter to one join P_SchedFirstOperation_Vers_2 as SchedFrstOp on CapRqmtItmCap.CapacityRequirement = SchedFrstOp.CapacityRequirement
// and CapRqmtItmCap.WorkCenterInternalID = SchedFrstOp.WorkCenterInternalID
// and CapRqmtItmCap.Operation = SchedFrstOp.Operation
// leftouter to one join I_OrderItem as _Ordermainitem on _Order.OrderID = _Ordermainitem.OrderID
// and _Ordermainitem.OrderItem = '0001'
// leftouter to one join I_SchedProdnProductionVersion as _ProductionVersion on _Ordermainitem.Material = _ProductionVersion.Material
// and _Ordermainitem.ProductionPlant = _ProductionVersion.Plant
// and _Ordermainitem.ProductionVersion = _ProductionVersion.ProductionVersion
// leftouter to one join I_WorkCenter as _workcenter on CapRqmtItmCap.WorkCenterInternalID = _workcenter.WorkCenterInternalID
// and _workcenter.WorkCenterTypeCode = 'A'
// association [1..1] to P_SchedOrderOperationStatus as _OrderStatus on _OrderStatus.StatusObject = CapRqmtItmCap.OrderObjectInternalID
{
keycast( _Order.OrderID as pph_cfs_ordernumber ) as orderid,
key CapRqmtItmCap.CapacityRequirementItem,
keycast(_Order.OrderCategory as pph_cfs_sch_ordercategory) as ordercategory,
key CapacityRqmtItemCapacity,
key CapRqmtItmCap.CapacityRequirement as CapacityRequirement,
cast( CapRqmtItmCap.Operation as vornr) as Operation,
OperationLatestStartDate,
OperationLatestStartTime,
OperationLatestEndDate,
OperationLatestEndTime,
casewhen _OrderOperation.OpDispatchedExecStartDate = '00000000'
thencast('DALL' as pph_cfs_sch_status)
elsecast('DSPT' as pph_cfs_sch_status)
endas OperationPlanningStatusCode,
// case// when _OrderStatus.StatusCode = 10 then 'I0001' /*Created*/// when _OrderStatus.StatusCode = 20 then 'I0002' /*Released*/// when _OrderStatus.StatusCode = 30 then 'I0009' /*Confirmed*/// when _OrderStatus.StatusCode = 40 then 'I0010' /*Partially Confirmed*/// when _OrderStatus.StatusCode != 10 and _OrderStatus.StatusCode != 20 and// _OrderStatus.StatusCode != 30 and _OrderStatus.StatusCode != 40
// then ' ' /*Should mainly incase maintainence order*/// endas StatusCode,
CapRqmtItmCap.OperationIsPhase
// cast(case// when SchedFrstOp.Operation isnot initial
// then// 'X'
// when SchedFrstOp.Operation is initial
// then ' '
// endas ppsch_is_first_operation_ind ) as OrderOperationIsFirstInSqnc,
// _ProductionVersion.ProductionLine as ProductionLine,
// _workcenter.WorkCenter as WorkCenter
}
where// CapRqmtItmCap.CapacityInternalID = _workcenter.CapacityInternalID
// and _workcenter.AdvancedPlanningIsSupported = ''
// and
(
_Order.OrderCategory = '10'
and _OrderOperation.Sequence = '000000'
or _Order.OrderCategory = '40'
and _OrderOperation.Sequence = '000000'
or _Order.OrderCategory = '30'
)
and(
CapRqmtItmCap.OperationIsPhase <> '2'
)
unionallselectfrom I_PlannedOrder as PlannedOrder
innerjoin I_SchedCapacityRqmtItemCap as CapRqmtItmCap on PlannedOrder.CapacityRequirement = CapRqmtItmCap.CapacityRequirement
and PlannedOrder.PlannedOrder = CapRqmtItmCap.PlannedOrder
leftouter to one join I_StatusObjectStatus as _OrderStatusObjectStatus on CapRqmtItmCap.OrderObjectInternalID = _OrderStatusObjectStatus.StatusObject
and _OrderStatusObjectStatus.StatusCode = 'I0117'
// leftouter to one join P_SchedFirstOperation_Vers_2 as SchedFrstOp on CapRqmtItmCap.CapacityRequirement = SchedFrstOp.CapacityRequirement
// and CapRqmtItmCap.WorkCenterInternalID = SchedFrstOp.WorkCenterInternalID
// and CapRqmtItmCap.Operation = SchedFrstOp.Operation
// leftouter to one join I_SchedProdnProductionVersion as _ProductionVersion on PlannedOrder.Material = _ProductionVersion.Material
// and PlannedOrder.MRPPlant = _ProductionVersion.Plant
// and PlannedOrder.ProductionVersion = _ProductionVersion.ProductionVersion
// leftouter to one join I_WorkCenter as _workcenter on CapRqmtItmCap.WorkCenterInternalID = _workcenter.WorkCenterInternalID
// and _workcenter.WorkCenterTypeCode = 'A'
{
keycast ( PlannedOrder.PlannedOrder as pph_cfs_ordernumber) as OrderID,
key CapRqmtItmCap.CapacityRequirementItem as CapacityRequirementItem,
keycast(PlannedOrder.PlannedOrderCategory as pph_cfs_sch_ordercategory) as OrderCategory,
key CapRqmtItmCap.CapacityRqmtItemCapacity,
key CapRqmtItmCap.CapacityRequirement as CapacityRequirement,
cast( CapRqmtItmCap.Operation as vornr) as Operation,
OperationLatestStartDate,
OperationLatestStartTime,
OperationLatestEndDate,
OperationLatestEndTime,
casewhen _OrderStatusObjectStatus.StatusCode = 'I0117' and _OrderStatusObjectStatus.StatusIsInactive = ''
thencast('DSPT' as pph_cfs_sch_status)
// when _OrderStatusObjectStatus.StatusCode != 'I0117' and _OrderStatusObjectStatus.StatusIsInactive != ''
elsecast('DALL' as pph_cfs_sch_status)
endas OperationPlanningStatusCode,
// 'I0001' /*showing planning orderas Created always*/as StatusCode,
CapRqmtItmCap.OperationIsPhase
// cast(case// when SchedFrstOp.Operation isnot initial
// then// 'X'
// when SchedFrstOp.Operation is initial
// then ' '
// endas ppsch_is_first_operation_ind ) as OrderOperationIsFirstInSqnc,
// _ProductionVersion.ProductionLine as ProductionLine,
// _workcenter.WorkCenter as WorkCenter
}
where
PlannedOrder.PlannedOrderCategory = '1'
and(
CapRqmtItmCap.OperationIsPhase <> '2'
)
// and CapRqmtItmCap.CapacityInternalID = _workcenter.CapacityInternalID
// and _workcenter.AdvancedPlanningIsSupported = ''