Derived SQL interpretation, reconstructed from the parsed view metadata (data sources, associations, and field mappings). SAP annotations are omitted and the structure is reformulated as SQL — this is a functional approximation, not the verbatim SAP source.
-- Derived SQL interpretation of CDS view P_EvaltCapWrkCtrCapOperations.
-- Reconstructed from parsed metadata (data sources, associations, fields).
-- SAP annotations are omitted and the structure is reformulated as SQL;
-- this is a functional approximation, not the verbatim SAP source. Some join
-- conditions may be unavailable and a few CDS constructs are kept as-is.
CREATE VIEW P_EvaltCapWrkCtrCapOperations AS
SELECT
workcenter_capacity.WorkCenterInternalID AS WorkCenterInternalID,
workcenter_capacity.WorkCenterTypeCode AS WorkCenterTypeCode,
workcenter_capacity.CapacityCategoryCode AS CapacityCategoryCode,
workcenter_capacity.CapacityCategoryAllocation AS CapacityCategoryAllocation,
CapRqmtItmCap.CapacityInternalID AS CapacityInternalID,
cast( _Order.OrderID as abap.char(12)) AS OrderID,
CapRqmtItmCap.Operation AS Operation,
CapRqmtItmCap.CapacityRequirement AS CapacityRequirement,
CapRqmtItmCap.CapacityRequirementItem AS CapacityRequirementItem,
_Order._OrderMainItem.Material AS Material,
_Order._OrderMainItem._Product.ProductGroup AS ProductGroup,
_Order._OrderMainItem.ProductConfiguration AS ProductConfiguration,
_Order.Plant AS Plant,
_Order.MRPController AS MRPController,
workcenter.WorkCenter AS WorkCenter,
CapRqmtItmCap.PlannedOrder AS PlannedOrder,
workcenter_capacity._Capacity.CapacityBaseQtyUnit AS CapacityBaseQtyUnit,
workcenter.WorkCenterResponsible AS WorkCenterResponsible,
workcenter.WorkCenterCategoryCode AS WorkCenterCategoryCode,
cast ('1' as capacityrequirementorigin) AS CapacityRequirementOrigin,
CapRqmtItmCap.OrderInternalID AS OrderInternalID,
_Order.OrderType AS OrderType,
cast( _Order.OrderCategory as pph_cfs_sch_ordercategory) AS OrderCategory,
_Order.OrderPlannedTotalQty AS OrderPlannedTotalQty,
_PlannedOrder.ProductionVersion AS ProductionVersion,
_Order.BaseUnit AS BaseUnit,
CapRqmtItmCap.OperationLatestStartDate AS OperationLatestStartDate,
CapRqmtItmCap.OperationLatestStartTime AS OperationLatestStartTime,
CapRqmtItmCap.OperationLatestEndDate AS OperationLatestEndDate,
CapRqmtItmCap.OperationLatestEndTime AS OperationLatestEndTime,
_OrderOperation.OpLtstSchedldProcgStrtDte AS OpLtstSchedldProcgStrtDte,
_OrderOperation.OpLtstSchedldProcgStrtTme AS OpLtstSchedldProcgStrtTme,
_OrderOperation.OpLtstSchedldTrdwnStrtDte AS OpLtstSchedldTrdwnStrtDte,
_OrderOperation.OpLtstSchedldTrdwnStrtTme AS OpLtstSchedldTrdwnStrtTme,
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 AS int4endasOpLtstSchedldExecStrtTme,
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 AS int4endasOpLtstSchedldExecEndTme,
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 AS dec163asCapacityRequirementsAreDtmnd,
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 AS dec102asRemainingCapReqOpSegSetupDurn,
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 AS dec102asRemainingCapReqOpSegProcgDurn,
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 AS dec102asRemainingCapReqOpSegTrdwnDurn,
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,
_OrderOperation.Sequence AS Sequence,
_Order._SalesOrder.SoldToParty AS Customer,
_Order._SalesOrder.SalesOrganization AS SalesOrganization,
_Order._SalesOrder.OrganizationDivision AS OrganizationDivision,
_Order._SalesOrder.DistributionChannel AS 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 AS AddressTimeZoneendasPlantTimeZone,
_OrderOper.StatusCode AS StatusCode,
cast( _Ordermainitem.MRPArea as berid) AS MRPArea
FROM I_LogisticsOrder AS _Order
INNER JOIN I_SchedCapacityRqmtItemCap AS CapRqmtItmCap ON /* join condition not captured in parsed metadata */
INNER JOIN I_WorkCenter AS workcenter ON /* join condition not captured in parsed metadata */
LEFT OUTER JOIN I_WorkCenterCapacity AS workcenter_capacity ON CapRqmtItmCap.WorkCenterInternalID = workcenter_capacity.WorkCenterInternalID AND CapRqmtItmCap.CapacityInternalID = workcenter_capacity.CapacityInternalID -- association [1..1]
LEFT OUTER JOIN I_PlannedOrder AS _PlannedOrder ON PlannedOrder = _PlannedOrder.PlannedOrder -- association [0..1]
LEFT OUTER JOIN I_CapacityRequirement AS _CapacityRequirement ON CapacityRequirement = _CapacityRequirement.CapacityRequirement -- association [1..1]
-- UNION ALL with additional select branch(es): I_PlannedOrder
;