P_RSHResourceCapacityKPIs is a Composite CDS View in SAP S/4HANA. It reads from 2 data sources (P_RSHResource, P_RSHResourceMonthlyUtilizatn) and exposes 8 fields with key fields EmploymentInternalId, YearMonth.
@AbapCatalog.sqlViewName: 'PRSHRESCAPKPIS'
@AbapCatalog.compiler.compareFilter: true@AccessControl.authorizationCheck: #CHECK@VDM.viewType: #COMPOSITE@VDM.private: true@ObjectModel.usageType.serviceQuality: #X@ObjectModel.usageType.dataClass: #MIXED@ObjectModel.usageType.sizeCategory: #XL@ClientHandling.algorithm: #SESSION_VARIABLE/*CONTRACT*******************************************************************************************************************
Name: Resource Capacity KPIs
Specification: Gives resource utilization info on a monthly basis between the given dates
Requires: Period for which the monthly capacity information is sought
Ensures: Monthly utilization percentage is returned for Resources for the specified period
Owners: PSP
Contributors: PSP
Unit Test required Y/N: N
Additional comments None
END OF CONTRACT**************************************************************************************************************/defineview P_RSHResourceCapacityKPIs
withparameters
P_StartDate : syst_datum,
P_EndDate : syst_datum
asselectfrom P_RSHResourceMonthlyUtilizatn( P_StartDate: $parameters.P_StartDate, P_EndDate:$parameters.P_EndDate)
innerjoin P_RSHResource( P_StartDate: $parameters.P_StartDate, P_EndDate:$parameters.P_EndDate) on P_RSHResource.EmploymentInternalId = P_RSHResourceMonthlyUtilizatn.EmploymentInternalId
{
key P_RSHResourceMonthlyUtilizatn.EmploymentInternalId,
key P_RSHResourceMonthlyUtilizatn.YearMonth,
P_RSHResource.CostCenter,
P_RSHResourceMonthlyUtilizatn.EmployeeStaffedHours,
P_RSHResourceMonthlyUtilizatn.EmployeeAvailableHours,
// Of course, Utilization = Staffed Hours / Available Hours!
casewhen P_RSHResourceMonthlyUtilizatn.EmployeeAvailableHours isnotnulland P_RSHResourceMonthlyUtilizatn.EmployeeAvailableHours > 0.00
//standard use-case: resource has available hours->simply divide for utilization
then division( P_RSHResourceMonthlyUtilizatn.EmployeeStaffedHours, P_RSHResourceMonthlyUtilizatn.EmployeeAvailableHours, 2) * 100
else//Resource either has no availability assigned or 0 available hours
casewhen P_RSHResourceMonthlyUtilizatn.EmployeeStaffedHours isnullor P_RSHResourceMonthlyUtilizatn.EmployeeStaffedHours = 0
//no availability, no staffing->0 utilization
thencast (0 asabap.int2)
else//no availability but staffings->return exception utilization rate
cast (999 asabap.int2)
endendas MonthlyUtilPercentage,
P_RSHResource.CompanyCode,
substring(P_RSHResourceMonthlyUtilizatn.YearMonth, 5, 2) as CalendarMonth
}