P_RSHCalWorkDaysTimeFrame is a Consumption CDS View in SAP S/4HANA. It reads from 2 data sources (P_RSHCALWORKDAYS, P_RSHOperationTimeFrame) and exposes 4 fields with key fields Client, WorkDays, CalendarDate, CapacityInternalID.
@AbapCatalog.sqlViewName: 'PRSHCALWDTF'
@AccessControl.authorizationCheck: #NOT_REQUIRED@VDM.private: true@VDM.viewType: #CONSUMPTION@ClientHandling.algorithm: #SESSION_VARIABLE/*
CONTRACT**********************************************************************************************************************
Name: Calander Working Days in Time Frame
Specification: This view retrieves the information on whether each day is a working day(1) ornot(0), as per the
factory calander
Requires: NA
Ensures: Information on whether each day is a working day(1) ornot(0), as per the factory calander
is returned. Only the days within the time range as per the underlying operations are included
in the results
Owners: PRP
Contributors: CK, AN
Unit Test required Y/N: Yes
Additional comments The below approach uses a CROSSJOIN to limit the date range that is involved.
The view P_RSHOperationTimeFrame also uses a CROSSJOIN.
This seems to be giving the best results in performance tests. Based on the feedback from
HANA DB team, this apporach could be improved or relooked in to
END OF CONTRACT***************************************************************************************************************
*/defineview P_RSHCalWorkDaysTimeFrame
withparameters
P_StartDate : datum,
P_EndDate : datum
asselectfrom P_RSHCALWORKDAYS( P_SAPClient : $session.client ) isWorkDay
crossjoin P_RSHOperationTimeFrame(P_StartDate : $parameters.P_StartDate, P_EndDate : $parameters.P_EndDate) as OperationsTimeFrame
{
key isWorkDay.client as Client,
key isWorkDay.WorkDays as WorkDays,
key isWorkDay.CalendarDate as CalendarDate,
key isWorkDay.CapacityInternalID as CapacityInternalID
}
where isWorkDay.CalendarDate >= OperationsTimeFrame.OperationTImeFrameStartDate and isWorkDay.CalendarDate <= OperationsTimeFrame.OperationTImeFrameEndDate