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_WorkCenterCapacityDefinition.
-- 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.
-- SQL view name: PWORKCTRCAPDEF
CREATE VIEW P_WorkCenterCapacityDefinition AS
SELECT
Header.WorkCenterInternalID AS WorkCenterInternalID,
Header.WorkCenterTypeCode AS WorkCenterTypeCode,
Header.CapacityCategoryAllocation AS CapacityCategoryAllocation,
Header.CapacityInternalID AS CapacityInternalID,
interval.AvailableCapacityType AS CapacityActiveVersion,
case when (shift_def.ShiftDefinition is not null) then case when shift_def.ShiftEndDate < interval.ValidityEndDate then shift_def.ShiftEndDate else interval.ValidityEndDate end else coalesce( interval.ValidityEndDate, Header.ValidityEndDate ) end as ValidityEndDate AS ValidityEndDateendasValidityEndDate,
coalesce( right( shift.WeekDay, 1), '1' ) AS WeekDay,
coalesce( shift.AvailableCapacityShift, '' ) AS AvailableCapacityShift,
Header.WorkCenter AS WorkCenter,
Header.Plant AS Plant,
Header.FactoryCalendar AS FactoryCalendar,
case when (shift_def.ShiftDefinition is not null) then case when shift_def.ShiftStartDate > interval.ValidityBeginDate then shift_def.ShiftStartDate else interval.ValidityBeginDate end else coalesce( interval.ValidityBeginDate, Header.ValidityBeginDate ) end as ValidityBeginDate AS ValidityBeginDateendasValidityBeginDate,
coalesce(shift_def.ShiftDefinition,'') AS ShiftName,
shift_def.ShiftDefinition AS ShiftDefinition,
Header.ShiftGroup AS ShiftGrouping,
case when (shift_def.ShiftDefinition is not null) then shift_def.ShiftStartDate else coalesce( interval.ValidityBeginDate, Header.ValidityBeginDate ) end as ShiftStartDate AS ValidityBeginDateendasShiftStartDate,
case when (shift_def.ShiftDefinition is not null) then shift_def.ShiftStartTime else cast ( substring( cast ( tstmp_add_seconds( cast ('10010102000000' as abap.dec(15,0)), cast( coalesce( shift.CapacityStartTimeID, Header.CapacityStartTime) as abap.dec(15,0) ), 'FAIL') as abap.sstring(50)), 9,6) as abap.tims) end as ShiftStartTime AS timsendasShiftStartTime,
case when (shift_def.ShiftDefinition is not null) then shift_def.ShiftEndDate else coalesce( interval.ValidityEndDate, Header.ValidityEndDate ) end as ShiftEndDate AS ValidityEndDateendasShiftEndDate,
case when (shift_def.ShiftDefinition is not null) then shift_def.ShiftEndTime when shift.CapacityEndTimeID = 86400 or (Header.CapacityEndTime = 86400 and shift.CapacityEndTimeID is null) then cast( '240000' as abap.tims ) else cast ( substring( cast ( tstmp_add_seconds( cast ('10010102000000' as abap.dec(15,0)), cast( coalesce( shift.CapacityEndTimeID, Header.CapacityEndTime) as abap.dec(15,0) ), 'FAIL') as abap.sstring(50)), 9,6) as abap.tims) end as ShiftEndTime AS timsendasShiftEndTime,
Header.WorkCenterResponsible AS WorkCenterResponsible,
Header.WorkCenterDesc AS WorkCenterDesc,
Header.WorkCenterCategoryCode AS WorkCenterCategoryCode,
Header.CapacityCategoryCode AS CapacityCategoryCode,
Header.CapacityCategoryName AS CapacityCategoryName,
Header.Capacity AS Capacity,
Header.CapacityResponsiblePlanner AS CapacityResponsiblePlanner,
coalesce( coalesce( shift_def.CapacityStartTimeID, shift.CapacityStartTimeID ), Header.CapacityStartTime ) as CapacityStartTime AS CapacityStartTimeasCapacityStartTime,
coalesce( coalesce( shift_def.CapacityEndTimeID, shift.CapacityEndTimeID ), Header.CapacityEndTime) as CapacityEndTime AS CapacityEndTimeasCapacityEndTime,
coalesce( interval.AvailableCapacityIntervalDurn, '01' ) AS AvailableCapacityIntervalDurn,
coalesce( interval.WorkDayRule, '' ) AS WorkDayRule,
case when (shift_def.ShiftDefinition is not null) then cast(shift_def.OperatingDurationInSeconds as abap.fltp) * cast(shift.CapacityNumberOfCapacities as abap.fltp) * cast(shift.CapacityPlanUtilizationPercent as abap.fltp) / cast(100 as abap.fltp) / cast (3600 as abap.fltp) else coalesce( shift.TotOperatingDurationInSeconds, Header.OverallCapacity ) / cast (3600 as abap.fltp) end as TotOperatingDurationInHours AS fltpendasTotOperatingDurationInHours,
case when (shift_def.ShiftDefinition is not null) then cast(shift_def.OperatingDurationInSeconds as abap.fltp) when shift.CapacityPlanUtilizationPercent is not null then case when shift.CapacityPlanUtilizationPercent > '000' then (cast(shift.OperatingDurationInSeconds as abap.fltp) * cast(100 as abap.fltp) / cast(shift.CapacityPlanUtilizationPercent as abap.fltp) ) else 0 end else cast(Header.SingleCapacity as abap.fltp) end as OperatingDurationInSeconds AS fltpendasOperatingDurationInSeconds,
coalesce( shift.CapacityNumberOfCapacities, Header.CapacityNumberOfCapacities) AS CapacityNumberOfCapacities,
coalesce( shift.CapacityPlanUtilizationPercent, Header.CapacityPlanUtilizationPercent) AS CapacityPlanUtilizationPercent
FROM P_WorkCenterHeaderCapacity AS Header
LEFT OUTER JOIN I_WorkCenterCapacityInterval AS interval ON /* join condition not captured in parsed metadata */
LEFT OUTER JOIN I_AvailableCapacityShift AS shift ON /* join condition not captured in parsed metadata */
LEFT OUTER JOIN P_WorkCenterShiftDefinition AS shift_def ON /* join condition not captured in parsed metadata */
;