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_RSHWCCapacityWithNights.
-- 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: PRSHWCCAPWNIGHT
CREATE VIEW P_RSHWCCapacityWithNights AS
SELECT
CapaDef.CapacityInternalID AS CapacityInternalID,
case when NightSplitDate = 2 and AvailableCapacityIntervalDurn = '07' then case CapaDef.WeekDay when '1' then '2' when '2' then '3' when '3' then '4' when '4' then '5' when '5' then '6' when '6' then '7' when '7' then '1' end else CapaDef.WeekDay end as WeekDay AS WeekDayendasWeekDay,
CapaDef.AvailableCapacityShift AS AvailableCapacityShift,
CapaDef.AvailableCapacityIntervalDurn AS AvailableCapacityIntervalDurn,
CapaDef.WorkDayRule AS WorkDayRule,
case when OperatingDurationInSeconds = 0 or NightSplitDate is null then OperatingDurationInSeconds else case when NightSplit.NightSplitDate = 1 then cast( 86400 - CapacityStartTime as abap.fltp) / ( cast ( 86400 - CapacityStartTime + CapacityEndTime as abap.fltp )) * cast(OperatingDurationInSeconds as abap.fltp) else cast(CapacityEndTime as abap.fltp) / ( cast ( 86400 - CapacityStartTime + CapacityEndTime as abap.fltp ) ) * cast(OperatingDurationInSeconds as abap.fltp) end end as OperatingDurationInSeconds AS fltpendendasOperatingDurationInSeconds,
case when NightSplitDate is null or CapacityBreakDuration = 0 or OperatingDurationInSeconds = 0 then CapacityBreakDuration else case when NightSplitDate = 1 then cast( 86400 - CapacityStartTime as abap.fltp) / ( cast( ( 86400 - CapacityStartTime + CapacityEndTime ) as abap.fltp ) ) * cast(CapacityBreakDuration as abap.fltp) else cast(CapacityEndTime as abap.fltp) / ( cast ( ( 86400 - CapacityStartTime + CapacityEndTime ) as abap.fltp ) ) * cast(CapacityBreakDuration as abap.fltp) end end as CapacityBreakDuration AS fltpendendasCapacityBreakDuration,
CapaDef.CapacityNumberOfCapacities AS CapacityNumberOfCapacities,
CapaDef.CapacityPlanUtilizationPercent AS CapacityPlanUtilizationPercent,
CapaDef.WorkCenterInternalID AS WorkCenterInternalID,
CapaDef.WorkCenter AS WorkCenter,
CapaDef.WorkCenterCategoryCode AS WorkCenterCategoryCode,
CapaDef.WorkCenterTypeCode AS WorkCenterTypeCode,
CapaDef.Plant AS Plant,
CapaDef.FactoryCalendar AS FactoryCalendar
FROM P_RSHWCCapacityDefinition AS CapaDef
LEFT OUTER JOIN P_RSHWCNightSplit AS NightSplit ON /* join condition not captured in parsed metadata */
;