P_Empworkinghours is a Composite CDS View in SAP S/4HANA. It reads from 3 data sources (I_CalendarDate, I_PersonWorkAgrmtStatus, I_PersonWorkAgrmtPlndWrkgTime) and exposes 4 fields with key fields PersonWorkAgreement, CalendarDate.
@AbapCatalog.sqlViewName: 'PEMPWORKHR'
@AbapCatalog.compiler.compareFilter: true@AccessControl.authorizationCheck: #NOT_REQUIRED@ClientHandling.algorithm: #SESSION_VARIABLE@VDM.viewType: #COMPOSITE@VDM.private: truedefineview P_Empworkinghours
asselectdistinctfrom I_PersonWorkAgrmtOrglDetails as Employment
innerjoin I_PersonWorkAgrmtStatus as EmpStatus on Employment.PersonWorkAgreement = EmpStatus.PersonWorkAgreement
//and CalendarDate.CalendarDate between EmpStatus.StartDate and EmpStatus.EndDate
and EmpStatus.WorkAgreementStatus = '1'
leftouterjoin I_CalendarDate as CalendarDate on CalendarDate.CalendarDate isnotnull//between $parameters.P_StartDate and $parameters.P_EndDate
leftouterjoin I_PersonWorkAgrmtPlndWrkgTime as WorkSchedule on Employment.PersonWorkAgreement = WorkSchedule.PersonWorkAgreement
and CalendarDate.CalendarDate between WorkSchedule.StartDate and WorkSchedule.EndDate
{
key Employment.PersonWorkAgreement,
key CalendarDate.CalendarDate,
// cast(Employment._EmploymentDetailsCurrent.WeeklyWorkdays as char7) as WeeklyWorkDays,
((WorkSchedule.WeeklyWorkdays)-cast(cast(CalendarDate._WeekDay.WeekDay as numc1 )asabap.dec(5,2))) as Difference,
@Semantics.unitOfMeasure: truecast('H' as meinh) as UnitOfMeasure,
// @DefaultAggregation: #NONE@Semantics.quantity.unitOfMeasure: 'UnitOfMeasure'
casewhen WorkSchedule.WeeklyWorkingHours > 0 and WorkSchedule.WeeklyWorkdays > 0
then division(WorkSchedule.WeeklyWorkingHours,WorkSchedule.WeeklyWorkdays, 3)
elsecast( 0 as pt_datthrs) //changed 8 to 0 from 1708
endas TotalPlannedHours
}
where
CalendarDate.CalendarDate between EmpStatus.StartDate and EmpStatus.EndDate
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_CALENDARDATE",
"I_PERSONWORKAGRMTORGLDETAILS",
"I_PERSONWORKAGRMTPLNDWRKGTIME",
"I_PERSONWORKAGRMTSTATUS",
"I_WEEKDAY"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/