@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---*/
define view P_Sched_Past_Operations
as select from I_LogisticsOrder as _Order
inner join I_SchedCapacityRqmtItemCap as CapRqmtItmCap on _Order.CapacityRequirement = CapRqmtItmCap.CapacityRequirement
left outer 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
// left outer to one join P_SchedFirstOperation_Vers_2 as SchedFrstOp on CapRqmtItmCap.CapacityRequirement = SchedFrstOp.CapacityRequirement
// and CapRqmtItmCap.WorkCenterInternalID = SchedFrstOp.WorkCenterInternalID
// and CapRqmtItmCap.Operation = SchedFrstOp.Operation
// left outer to one join I_OrderItem as _Ordermainitem on _Order.OrderID = _Ordermainitem.OrderID
// and _Ordermainitem.OrderItem = '0001'
// left outer to one join I_SchedProdnProductionVersion as _ProductionVersion on _Ordermainitem.Material = _ProductionVersion.Material
// and _Ordermainitem.ProductionPlant = _ProductionVersion.Plant
// and _Ordermainitem.ProductionVersion = _ProductionVersion.ProductionVersion
// left outer 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
{
key cast( _Order.OrderID as pph_cfs_ordernumber ) as orderid,
key CapRqmtItmCap.CapacityRequirementItem,
key cast(_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,
case
when _OrderOperation.OpDispatchedExecStartDate = '00000000'
then cast('DALL' as pph_cfs_sch_status)
else
cast('DSPT' as pph_cfs_sch_status)
end as 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 in case maintainence order*/
// end as StatusCode,
CapRqmtItmCap.OperationIsPhase
// cast(case
// when SchedFrstOp.Operation is not initial
// then
// 'X'
// when SchedFrstOp.Operation is initial
// then ' '
// end as 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'
)
union all select from I_PlannedOrder as PlannedOrder
inner join I_SchedCapacityRqmtItemCap as CapRqmtItmCap on PlannedOrder.CapacityRequirement = CapRqmtItmCap.CapacityRequirement
and PlannedOrder.PlannedOrder = CapRqmtItmCap.PlannedOrder
left outer to one join I_StatusObjectStatus as _OrderStatusObjectStatus on CapRqmtItmCap.OrderObjectInternalID = _OrderStatusObjectStatus.StatusObject
and _OrderStatusObjectStatus.StatusCode = 'I0117'
// left outer to one join P_SchedFirstOperation_Vers_2 as SchedFrstOp on CapRqmtItmCap.CapacityRequirement = SchedFrstOp.CapacityRequirement
// and CapRqmtItmCap.WorkCenterInternalID = SchedFrstOp.WorkCenterInternalID
// and CapRqmtItmCap.Operation = SchedFrstOp.Operation
// left outer to one join I_SchedProdnProductionVersion as _ProductionVersion on PlannedOrder.Material = _ProductionVersion.Material
// and PlannedOrder.MRPPlant = _ProductionVersion.Plant
// and PlannedOrder.ProductionVersion = _ProductionVersion.ProductionVersion
// left outer to one join I_WorkCenter as _workcenter on CapRqmtItmCap.WorkCenterInternalID = _workcenter.WorkCenterInternalID
// and _workcenter.WorkCenterTypeCode = 'A'
{
key cast ( PlannedOrder.PlannedOrder as pph_cfs_ordernumber) as OrderID,
key CapRqmtItmCap.CapacityRequirementItem as CapacityRequirementItem,
key cast(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,
case
when _OrderStatusObjectStatus.StatusCode = 'I0117' and _OrderStatusObjectStatus.StatusIsInactive = ''
then cast('DSPT' as pph_cfs_sch_status)
// when _OrderStatusObjectStatus.StatusCode != 'I0117' and _OrderStatusObjectStatus.StatusIsInactive != ''
else
cast('DALL' as pph_cfs_sch_status)
end as OperationPlanningStatusCode,
// 'I0001' /*showing planning order as Created always*/ as StatusCode,
CapRqmtItmCap.OperationIsPhase
// cast(case
// when SchedFrstOp.Operation is not initial
// then
// 'X'
// when SchedFrstOp.Operation is initial
// then ' '
// end as 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 = ''
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_LOGISTICSORDER",
"I_ORDEROPERATION",
"I_PLANNEDORDER",
"I_SCHEDCAPACITYRQMTITEMCAP",
"I_STATUSOBJECTSTATUS"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/