@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.viewType: #COMPOSITE
@VDM: {
private: true
}
@Metadata.ignorePropagatedAnnotations: true
define view entity P_EvaltCapWrkCtrCapOperations
as select from I_LogisticsOrder as _Order
inner join I_SchedCapacityRqmtItemCap as CapRqmtItmCap on _Order.CapacityRequirement = CapRqmtItmCap.CapacityRequirement
inner join I_WorkCenter as workcenter on CapRqmtItmCap.WorkCenterInternalID = workcenter.WorkCenterInternalID
and workcenter.WorkCenterIsToBeDeleted = ''
and workcenter.WorkCenterTypeCode = 'A'
// left outer to one join afko as _OrderHeader on CapRqmtItmCap.OrderInternalID = _OrderHeader.aufpl
// and CapRqmtItmCap.OrderInternalID > '0000000000'
left outer to many join I_OrderOperation as _OrderOperation on CapRqmtItmCap.OrderInternalID = _OrderOperation.OrderInternalID
and CapRqmtItmCap.OrderOperationInternalID = _OrderOperation.OrderOperationInternalID
and CapRqmtItmCap.WorkCenterInternalID = _OrderOperation.WorkCenterInternalID
// and CapRqmtItmCap.OperationLatestStartDate = _OrderOperation.OpLtstSchedldExecStrtDte
// and CapRqmtItmCap.OperationLatestEndDate = _OrderOperation.OpLtstSchedldExecEndDte
and _OrderOperation.SuperiorOperationInternalID is initial
// and _OrderOperation.Sequence = '000000'
// left outer join P_MfgOrderOpStatus as _OrderOper on CapRqmtItmCap.OrderInternalID = _OrderOper.OrderInternalID
// and _OrderOperation.OrderOperationInternalID = _OrderOper.OrderOperationInternalID
left outer to one join P_MfgOrderOpStatus as _OrderOper on CapRqmtItmCap.OrderObjectInternalID = _OrderOper.StatusObject
// and _OrderOper.StatusCode <> 30
left outer to one join P_ProcCapReqOpDurn as ProcOpDurn on CapRqmtItmCap.CapacityRequirement = ProcOpDurn.CapacityRequirement
and CapRqmtItmCap.CapacityRequirementItem = ProcOpDurn.SuperiorOperationInternalID
and CapRqmtItmCap.CapacityRqmtItemCapacity = ProcOpDurn.CapacityRqmtItemCapacity
and CapRqmtItmCap.OperationIsPhase = '1'
left outer to one join I_OrderItem as _Ordermainitem on _Order.OrderID = _Ordermainitem.OrderID
and _Ordermainitem.OrderItem = '0001'
// association [0..1] to I_LogisticsOrder as _Order on _OrderHeader.aufnr = _Order.OrderID
association [1..1] to I_WorkCenterCapacity as workcenter_capacity on CapRqmtItmCap.WorkCenterInternalID = workcenter_capacity.WorkCenterInternalID
and CapRqmtItmCap.CapacityInternalID = workcenter_capacity.CapacityInternalID
// association [1..1] to I_CapacityRequirement as _CapacityRequirement on $projection.CapacityRequirement = _CapacityRequirement.CapacityRequirement
association [0..1] to I_PlannedOrder as _PlannedOrder on $projection.PlannedOrder = _PlannedOrder.PlannedOrder
// association [1..1] to P_SchedOrderOperationStatus as _OrderOper on _OrderOper.StatusObject = CapRqmtItmCap.OrderObjectInternalID
// association [1..1] to P_MfgOrderOpStatus as _OrderOper on CapRqmtItmCap.OrderInternalID = _OrderOper.OrderInternalID
// and _OrderOperation.OrderOperationInternalID = _OrderOper.OrderOperationInternalID
// association [0..*] to I_OrderOperation as _OrderOperation on CapRqmtItmCap.OrderInternalID = _OrderOperation.OrderInternalID
// and CapRqmtItmCap.OrderOperationInternalID = _OrderOperation.OrderOperationInternalID
// //and CapRqmtItmCap.WorkCenterInternalID = _OrderOperation.WorkCenterInternalID
// and _OrderOperation.SuperiorOperationInternalID is initial
// and _OrderOperation.Sequence = '000000'
//association [0..1] to I_MfgOrderItem as _MfgOrderItem on $projection.OrderID = _MfgOrderItem.ManufacturingOrder
// and $projection.OrderCategory = '10'
// and _MfgOrderItem.ManufacturingOrderItem = '0001'
{
key workcenter_capacity.WorkCenterInternalID as WorkCenterInternalID,
key workcenter_capacity.WorkCenterTypeCode,
key workcenter_capacity.CapacityCategoryCode,
key workcenter_capacity.CapacityCategoryAllocation,
key CapRqmtItmCap.CapacityInternalID as CapacityInternalID,
key cast( _Order.OrderID as abap.char(12)) as OrderID, //
//key _Order.OrderID,
key CapRqmtItmCap.Operation as Operation,
key CapRqmtItmCap.CapacityRequirement as CapacityRequirement,
key CapRqmtItmCap.CapacityRequirementItem as CapacityRequirementItem,
//key cast( _Order.Material as matnr) as Material, //
// _Order.Material,
_Order._OrderMainItem.Material,
_Order._OrderMainItem._Product.ProductGroup as ProductGroup,
_Order._OrderMainItem.ProductConfiguration as ProductConfiguration,
// _MfgOrderItem.Material,
//cast( _Order.Plant as abap.char(4)) as Plant, //
_Order.Plant,
//cast( _Order.MRPController as abap.char(3)) as MRPController, //
_Order.MRPController,
workcenter.WorkCenter,
CapRqmtItmCap.PlannedOrder,
workcenter_capacity._Capacity.CapacityBaseQtyUnit as CapacityBaseQtyUnit,
case
when CapRqmtItmCap.OperationIsPhase = '1'
then ProcOpDurn.CapacityRequirementUnit
when CapRqmtItmCap.OperationIsPhase <> '1'
then
CapRqmtItmCap.CapacityRequirementUnit
end as CapacityRequirementUnit,
workcenter.WorkCenterResponsible as WorkCenterResponsible,
workcenter.WorkCenterCategoryCode,
// Removing the association to I_CapacityRequirement as the data returned is already having CapacityRequirementOrigin=1
// Hardcoding the CapacityRequirementOrigin to 1 for the above reason
//_CapacityRequirement.CapacityRequirementOrigin as CapacityRequirementOrigin,
cast ('1' as capacityrequirementorigin) as CapacityRequirementOrigin,
CapRqmtItmCap.OrderInternalID as OrderInternalID,
//cast( _Order.OrderType as abap.char(4)) as OrderType, //
_Order.OrderType,
// case CapRqmtItmCap._CapacityRequirement.CapacityRequirementOrigin
// when '1'
// then CapRqmtItmCap._Order._OrderType._Text[1:Language=$session.system_language].OrderTypeName
// when '2'
// then CapRqmtItmCap._PlannedOrder._PlannedOrderType._Text[1:Language=$session.system_language].PlannedOrderTypeName
// else ''
// end as OrderTypeName,
cast( _Order.OrderCategory as pph_cfs_sch_ordercategory) as OrderCategory, //
//cast( _Order.OrderCategory as pph_autyp ) as OrderCategory,
// case CapRqmtItmCap._CapacityRequirement.CapacityRequirementOrigin
// when '1'
// then CapRqmtItmCap._Order._OrderCategory._Text[1:Language=$session.system_language].OrderCategoryName
// when '2'
// then CapRqmtItmCap._PlannedOrder._PlannedOrderCategory._Text[1:Language=$session.system_language].PlannedOrderCategoryName
// else ''
// end as OrderCategoryName,
//cast ( _Order.OrderPlannedTotalQty as abap.quan(13,3) ) as OrderPlannedTotalQty, //
//@Semantics.quantity.unitOfMeasure: 'BaseUnit'
@Semantics.quantity.unitOfMeasure: 'BaseUnit'
_Order.OrderPlannedTotalQty,
_PlannedOrder.ProductionVersion as ProductionVersion,
_Order.BaseUnit as BaseUnit, //
case
when _OrderOperation.OpDispatchedExecStartDate is initial or _OrderOperation.OpDispatchedExecStartDate is null
then 'DALL'
when _OrderOperation.OpDispatchedExecStartDate is not initial
then 'DSPT'
end as OperationPlanningStatusCode, //
// case
// when _Order.OrderCategory = '30'
// then CapRqmtItmCap.OperationLatestStartDate
// when _Order.OrderCategory <> '30'
// then _OrderOperation.OpLtstSchedldExecStrtDte
// end as OperationLatestStartDate, //
//Operation Latest Start and End Date/Time is picked from KBED
CapRqmtItmCap.OperationLatestStartDate,
// case
// when _Order.OrderCategory = '30'
// then CapRqmtItmCap.OperationLatestStartTime
// when _Order.OrderCategory <> '30'
// then _OrderOperation.OpLtstSchedldExecStrtTme
// end as OperationLatestStartTime, //
CapRqmtItmCap.OperationLatestStartTime,
// case
// when _Order.OrderCategory = '30'
// then CapRqmtItmCap.OperationLatestEndDate
// when _Order.OrderCategory <> '30'
// then _OrderOperation.LatestScheduledWaitEndDate
// end as OperationLatestEndDate, //
CapRqmtItmCap.OperationLatestEndDate,
// case
// when _Order.OrderCategory = '30'
// then CapRqmtItmCap.OperationLatestEndTime
// when _Order.OrderCategory <> '30'
// then _OrderOperation.LatestScheduledWaitEndTime
// end as OperationLatestEndTime, //
CapRqmtItmCap.OperationLatestEndTime,
_OrderOperation.OpLtstSchedldProcgStrtDte as OpLtstSchedldProcgStrtDte, //
_OrderOperation.OpLtstSchedldProcgStrtTme as OpLtstSchedldProcgStrtTme, //
_OrderOperation.OpLtstSchedldTrdwnStrtDte as OpLtstSchedldTrdwnStrtDte, //
_OrderOperation.OpLtstSchedldTrdwnStrtTme as OpLtstSchedldTrdwnStrtTme, //
//Convert time into seconds
case
when _Order.OrderCategory <> '30'
then
cast( cast( substring( _OrderOperation.OpLtstSchedldExecStrtTme, 1, 2) as abap.numc(2) ) as abap.int4 ) * 3600 +
cast( cast( substring( _OrderOperation.OpLtstSchedldExecStrtTme, 3, 2) as abap.numc(2) ) as abap.int4 ) * 60 +
cast( cast( substring( _OrderOperation.OpLtstSchedldExecStrtTme, 5, 2) as abap.numc(2) ) as abap.int4 )
when _Order.OrderCategory = '30'
then
cast( cast( substring( CapRqmtItmCap.OperationLatestStartTime, 1, 2) as abap.numc(2) ) as abap.int4 ) * 3600 +
cast( cast( substring( CapRqmtItmCap.OperationLatestStartTime, 3, 2) as abap.numc(2) ) as abap.int4 ) * 60 +
cast( cast( substring( CapRqmtItmCap.OperationLatestStartTime, 5, 2) as abap.numc(2) ) as abap.int4 )
end as OpLtstSchedldExecStrtTme, //
case
when _Order.OrderCategory <> '30'
then
cast( cast( substring( _OrderOperation.LatestScheduledWaitEndTime, 1, 2) as abap.numc(2) ) as abap.int4 ) * 3600 +
cast( cast( substring( _OrderOperation.LatestScheduledWaitEndTime, 3, 2) as abap.numc(2) ) as abap.int4 ) * 60 +
cast( cast( substring( _OrderOperation.LatestScheduledWaitEndTime, 5, 2) as abap.numc(2) ) as abap.int4 )
when _Order.OrderCategory = '30'
then
cast( cast( substring( CapRqmtItmCap. OperationLatestEndTime, 1, 2) as abap.numc(2) ) as abap.int4 ) * 3600 +
cast( cast( substring(CapRqmtItmCap. OperationLatestEndTime, 3, 2) as abap.numc(2) ) as abap.int4 ) * 60 +
cast( cast( substring( CapRqmtItmCap. OperationLatestEndTime, 5, 2) as abap.numc(2) ) as abap.int4 )
end as OpLtstSchedldExecEndTme, //
// cast( case
// when CapRqmtItmCap.OperationIsPhase = '1'
// then ProcOpDurn.TotRemCapReqOpSegProcgDurn
// when CapRqmtItmCap.OperationIsPhase <> '1'
// then
// (( CapRqmtItmCap.RemainingCapReqOpSegSetupDurn
// + CapRqmtItmCap.RemainingCapReqOpSegTrdwnDurn
// + CapRqmtItmCap.RemainingCapReqOpSegProcgDurn ) )
// end as abap.dec(10,2) ) as CapacityRequirementsAreDtmnd,
//
cast( case
when CapRqmtItmCap.OperationIsPhase = '1'
then ProcOpDurn.TotRemCapReqOpSegProcgDurn
when CapRqmtItmCap.OperationIsPhase <> '1'
then
(( CapRqmtItmCap.RemainingCapReqOpSegSetupDurn
+ CapRqmtItmCap.RemainingCapReqOpSegTrdwnDurn
+ CapRqmtItmCap.RemainingCapReqOpSegProcgDurn ) )
end as abap.dec(16,3) ) as CapacityRequirementsAreDtmnd,
//
cast('H' as char1) as char_man,
cast( case
when CapRqmtItmCap.RemainingCapReqOpSegSetupDurn > 99999999
then fltp_to_dec(99999999.99 as abap.dec( 10,2))
when CapRqmtItmCap.RemainingCapReqOpSegSetupDurn <= 99999999
then fltp_to_dec(CapRqmtItmCap.RemainingCapReqOpSegSetupDurn as abap.dec( 10,2))
end as abap.dec(10,2) ) as RemainingCapReqOpSegSetupDurn,
// case
// when CapRqmtItmCap.OperationIsPhase = '1'
// then case
// when ProcOpDurn.TotRemCapReqOpSegProcgDurn > 99999999
// then fltp_to_dec(99999999.99 as abap.dec( 10,2))
// else fltp_to_dec(ProcOpDurn.TotRemCapReqOpSegProcgDurn as abap.dec( 10,2))
// end
// else
// case
// when CapRqmtItmCap.RemainingCapReqOpSegProcgDurn > 99999999
// then fltp_to_dec(99999999.99 as abap.dec( 10,2))
// else fltp_to_dec(CapRqmtItmCap.RemainingCapReqOpSegProcgDurn as abap.dec( 10,2))
// end
// end as RemainingCapReqOpSegProcgDurn,
cast( case
when CapRqmtItmCap.OperationIsPhase = '1' and ProcOpDurn.TotRemCapReqOpSegProcgDurn > 99999999
then fltp_to_dec(99999999.99 as abap.dec( 10,2))
when CapRqmtItmCap.OperationIsPhase = '1' and ProcOpDurn.TotRemCapReqOpSegProcgDurn <= 99999999
then fltp_to_dec(ProcOpDurn.TotRemCapReqOpSegProcgDurn as abap.dec( 10,2))
when CapRqmtItmCap.OperationIsPhase <> '1' and ProcOpDurn.TotRemCapReqOpSegProcgDurn > 99999999
then fltp_to_dec(99999999.99 as abap.dec( 10,2))
when CapRqmtItmCap.OperationIsPhase <> '1' and ProcOpDurn.TotRemCapReqOpSegProcgDurn <= 99999999
then fltp_to_dec(CapRqmtItmCap.RemainingCapReqOpSegProcgDurn as abap.dec( 10,2))
end as abap.dec(10,2) ) as RemainingCapReqOpSegProcgDurn,
cast( case
when CapRqmtItmCap.RemainingCapReqOpSegTrdwnDurn > 99999999
then fltp_to_dec(99999999.99 as abap.dec( 10,2))
when CapRqmtItmCap.RemainingCapReqOpSegTrdwnDurn <= 99999999
then fltp_to_dec(CapRqmtItmCap.RemainingCapReqOpSegTrdwnDurn as abap.dec( 10,2))
end as abap.dec(10,2) ) as RemainingCapReqOpSegTrdwnDurn,
// case CapRqmtItmCap._CapacityRequirement.CapacityRequirementOrigin
// when '1'
// then case _OrderOper.StatusCode
// when 10 then 'Created'
// when 20 then 'Released'
// when 30 then 'Confirmed'
// when 40 then 'Partially Confirmed'
// end
// when '2'
// then 'Created'
// end as OrderStatusText,
case
when _Order.OrderCategory = '30'
then ' '
when _Order.OrderCategory <> '30' and _OrderOper.StatusCode = 10
then 'I0001'
when _Order.OrderCategory <> '30' and _OrderOper.StatusCode = 20
then 'I0002'
when _Order.OrderCategory <> '30' and _OrderOper.StatusCode = 30
then 'I0009'
when _Order.OrderCategory <> '30' and _OrderOper.StatusCode = 40
then 'I0010'
end as OrderStatusCode,
// case
// when _OrderOper.StatusCode = 10 then 'I0001' /*Created*/
// when _OrderOper.StatusCode = 20 then 'I0002' /*Released*/
//// when _OrderOper.StatusCode = 30 then 'I0009' /*Confirmed*/
// when _OrderOper.StatusCode = 40 then 'I0010' /*Partially Confirmed*/
// when _OrderOper.StatusCode != 10 and _OrderOper.StatusCode != 20 and
// _OrderOper.StatusCode != 30 and _OrderOper.StatusCode != 40
// then ' ' /*Should mainly in case maintainence order*/
// end as OrderStatusCode,
cast('0' as char1) as OrderFirmingStatusCode, //
_Order.ScheduledBasicStartDate as ScheduledBasicStartDate, //
_Order.ScheduledBasicStartTime as ScheduledBasicStartTime, //
_Order.ScheduledBasicEndDate as ScheduledBasicEndDate, //
_Order.ScheduledBasicEndTime as ScheduledBasicEndTime, //
$session.system_date as CurrentDate,
case
when CapRqmtItmCap.OperationLatestStartTime >= '240000'
then cast(cast(concat(dats_add_days(CapRqmtItmCap.OperationLatestStartDate,1,'NULL'),'000000')as abap.numc(15)) as timestamp)
when CapRqmtItmCap.OperationLatestStartTime < '240000'
then
cast(cast(concat(CapRqmtItmCap.OperationLatestStartDate,CapRqmtItmCap.OperationLatestStartTime)as abap.numc(15)) as timestamp)
end as LtstSchedldExecStrtDteTme,
case
when CapRqmtItmCap.OperationLatestEndTime >= '240000'
then cast(cast(concat(dats_add_days(CapRqmtItmCap.OperationLatestEndDate,1,'NULL'),'000000')as abap.numc(15)) as timestamp)
when CapRqmtItmCap.OperationLatestEndTime < '240000'
then cast(cast(concat(CapRqmtItmCap.OperationLatestEndDate,CapRqmtItmCap.OperationLatestEndTime)as abap.numc(15)) as timestamp)
end as LtstSchedldExecEndDteTme,
_OrderOperation.Sequence as Sequence,
_Order._SalesOrder.SoldToParty as Customer,
_Order._SalesOrder.SalesOrganization,
_Order._SalesOrder.OrganizationDivision,
_Order._SalesOrder.DistributionChannel,
case
when workcenter._Plant._OrganizationAddress[1: AddressRepresentationCode = '' ].AddressTimeZone is null or workcenter._Plant._OrganizationAddress[1: AddressRepresentationCode = '' ].AddressTimeZone is initial
then abap_system_timezone($session.client, 'NULL')
when workcenter._Plant._OrganizationAddress[1: AddressRepresentationCode = '' ].AddressTimeZone is not null
then workcenter._Plant._OrganizationAddress[1: AddressRepresentationCode = '' ].AddressTimeZone
end as PlantTimeZone,
_OrderOper.StatusCode,
cast( _Ordermainitem.MRPArea as berid) as MRPArea
}
where
// _CapacityRequirement.CapacityRequirementOrigin = '1'
// and(
CapRqmtItmCap.OperationIsPhase <> '2'
// )
and(
_Order.OrderCategory = '10'
// and _OrderOperation.Sequence = '000000'
or _Order.OrderCategory = '40'
// and _OrderOperation.Sequence = '000000'
or _Order.OrderCategory = '30'
)
and ( _OrderOper.StatusCode = 10 or
_OrderOper.StatusCode = 20 or
_OrderOper.StatusCode = 40 )
//and OperationLatestStartDate <= $parameters.P_EndDate
// and OperationLatestEndDate >= $parameters.P_StartDate
union all
//select from I_SchedCapacityRqmtItemCap as CapRqmtItmCap
select from I_PlannedOrder as _PlannedOrder
inner join I_SchedCapacityRqmtItemCap as CapRqmtItmCap on _PlannedOrder.CapacityRequirement = CapRqmtItmCap.CapacityRequirement
inner join I_WorkCenter as workcenter on CapRqmtItmCap.WorkCenterInternalID = workcenter.WorkCenterInternalID
and workcenter.WorkCenterIsToBeDeleted = ''
and workcenter.WorkCenterTypeCode = 'A'
left outer to one 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_WorkCenterCapacity as workcenter_capacity on CapRqmtItmCap.WorkCenterInternalID = workcenter_capacity.WorkCenterInternalID
and CapRqmtItmCap.CapacityInternalID = workcenter_capacity.CapacityInternalID
//association [0..1] to I_PlannedOrder as _PlannedOrder on $projection.PlannedOrder = _PlannedOrder.PlannedOrder
association [1..1] to I_CapacityRequirement as _CapacityRequirement on $projection.CapacityRequirement = _CapacityRequirement.CapacityRequirement
{
key workcenter_capacity.WorkCenterInternalID as WorkCenterInternalID,
key workcenter_capacity.WorkCenterTypeCode,
key workcenter_capacity.CapacityCategoryCode,
key workcenter_capacity.CapacityCategoryAllocation,
key CapRqmtItmCap.CapacityInternalID as CapacityInternalID,
key cast ( CapRqmtItmCap.PlannedOrder as abap.char(12) ) as OrderID,
key CapRqmtItmCap.Operation as Operation,
key CapRqmtItmCap.CapacityRequirement as CapacityRequirement,
key CapRqmtItmCap.CapacityRequirementItem as CapacityRequirementItem,
//key cast ( _PlannedOrder.Material as matnr ) as Material,
_PlannedOrder.Material,
_PlannedOrder._Product.ProductGroup as ProductGroup,
cast( '' as cuobj ) as ProductConfiguration,
//cast ( _PlannedOrder.ProductionPlant as abap.char(4) ) as Plant,
_PlannedOrder.ProductionPlant as Plant,
//cast ( _PlannedOrder.MRPController as abap.char(3) ) as MRPController,
_PlannedOrder.MRPController as MRPController,
workcenter.WorkCenter,
CapRqmtItmCap.PlannedOrder,
workcenter_capacity._Capacity.CapacityBaseQtyUnit as CapacityBaseQtyUnit,
// case
// when CapRqmtItmCap.OperationIsPhase = '1'
// then ProcOpDurn.CapacityRequirementUnit
// else
// CapRqmtItmCap.CapacityRequirementUnit
// end as CapacityRequirementUnit,
case
when CapRqmtItmCap.OperationIsPhase = '1'
then ProcOpDurn.CapacityRequirementUnit
when CapRqmtItmCap.OperationIsPhase <> '1'
then
CapRqmtItmCap.CapacityRequirementUnit
end as CapacityRequirementUnit,
workcenter.WorkCenterResponsible as WorkCenterResponsible,
workcenter.WorkCenterCategoryCode,
// _Text[1:Language=$session.system_language].WorkCenterText as WorkCenterDesc,
_CapacityRequirement.CapacityRequirementOrigin as CapacityRequirementOrigin,
CapRqmtItmCap.OrderInternalID as OrderInternalID,
cast ( _PlannedOrder.PlannedOrderType as abap.char(3) ) as OrderType,
cast(_PlannedOrder.PlannedOrderCategory as pph_cfs_sch_ordercategory) as OrderCategory,
//cast ( _PlannedOrder.PlannedTotalQtyInBaseUnit as abap.quan(13,3) ) as OrderPlannedTotalQty,
//@Semantics.quantity.unitOfMeasure: 'BaseUnit'
_PlannedOrder.PlannedTotalQtyInBaseUnit as OrderPlannedTotalQty,
_PlannedOrder.ProductionVersion as ProductionVersion,
_PlannedOrder.BaseUnit as BaseUnit,
case
when _PlannedOrder.PlannedOrderCapacityIsDsptchd = 'X'
then 'DSPT'
when _PlannedOrder.PlannedOrderCapacityIsDsptchd <> 'X'
then 'DALL'
end as OperationPlanningStatusCode,
CapRqmtItmCap.OperationLatestStartDate as OperationLatestStartDate,
CapRqmtItmCap.OperationLatestStartTime as OperationLatestStartTime,
CapRqmtItmCap.OperationLatestEndDate as OperationLatestEndDate,
CapRqmtItmCap. OperationLatestEndTime as OperationLatestEndTime,
CapRqmtItmCap.LtstSchedldProcStrtDte as OpLtstSchedldProcgStrtDte,
CapRqmtItmCap.LtstSchedldProcStrtTime as