P_WorkCenterAvailableCapacity
Total Available Capacity of Work Center
P_WorkCenterAvailableCapacity is a Composite CDS View that provides data about "Total Available Capacity of Work Center" in SAP S/4HANA. It reads from 3 data sources (P_CapacityDefinition, I_WorkCenterCapacity, P_WrkCtrWorkDays) and exposes 34 fields with key fields WorkCenterInternalID, WorkCenterTypeCode, CapacityCategoryAllocation, CapacityInternalID, CapacityActiveVersion. Part of development package PPH_VDM_CAP_EVAL.
Data Sources (3)
| Source | Alias | Join Type |
|---|---|---|
| P_CapacityDefinition | CapacityPerShift | inner |
| I_WorkCenterCapacity | WorkCenterCapacity | from |
| P_WrkCtrWorkDays | WorkDays | inner |
Annotations (6)
| Name | Value | Level | Field |
|---|---|---|---|
| ClientHandling.algorithm | #SESSION_VARIABLE | view | |
| AbapCatalog.sqlViewName | PWRKCTRAVAILCAP | view | |
| AbapCatalog.compiler.compareFilter | true | view | |
| AccessControl.authorizationCheck | #NOT_REQUIRED | view | |
| VDM.viewType | #COMPOSITE | view | |
| VDM.private | true | view |
Fields (34)
| Key | Field | Source Table | Source Field | Description |
|---|---|---|---|---|
| KEY | WorkCenterInternalID | I_WorkCenterCapacity | WorkCenterInternalID | |
| KEY | WorkCenterTypeCode | I_WorkCenterCapacity | WorkCenterTypeCode | |
| KEY | CapacityCategoryAllocation | I_WorkCenterCapacity | CapacityCategoryAllocation | |
| KEY | CapacityInternalID | I_WorkCenterCapacity | CapacityInternalID | |
| KEY | CapacityActiveVersion | P_CapacityDefinition | CapacityActiveVersion | |
| KEY | ValidityEndDate | P_CapacityDefinition | ValidityEndDate | |
| KEY | WeekDay | |||
| KEY | AvailableCapacityShift | P_CapacityDefinition | AvailableCapacityShift | |
| KEY | CalendarDate | P_WrkCtrWorkDays | CalendarDate | |
| ShiftStartDate | P_CapacityDefinition | ShiftStartDate | ||
| ShiftStartTime | P_CapacityDefinition | ShiftStartTime | ||
| ShiftEndDate | P_CapacityDefinition | ShiftEndDate | ||
| ShiftEndTime | P_CapacityDefinition | ShiftEndTime | ||
| CapacityBreakDuration | ||||
| WorkCenterCapacityUnit | ||||
| WorkCenterUtilizationUnit | ||||
| ValidityBeginDate | P_CapacityDefinition | ValidityBeginDate | ||
| CalendarMonth | P_WrkCtrWorkDays | CalendarMonth | ||
| CalendarYear | P_WrkCtrWorkDays | CalendarYear | ||
| CalendarWeek | P_WrkCtrWorkDays | CalendarWeek | ||
| workdays | P_WrkCtrWorkDays | workdays | ||
| WorkCenterPlant | P_CapacityDefinition | Plant | ||
| CapacityCategoryCode | P_CapacityDefinition | CapacityCategoryCode | ||
| ShiftNameendasShiftName | ||||
| ShiftDefinition | P_CapacityDefinition | ShiftDefinition | ||
| ShiftGrouping | P_CapacityDefinition | ShiftGrouping | ||
| WorkDayRule | P_CapacityDefinition | WorkDayRule | ||
| FactoryCalendar | P_CapacityDefinition | FactoryCalendar | ||
| CapacityStartTime | P_CapacityDefinition | CapacityStartTime | ||
| CapacityEndTime | P_CapacityDefinition | CapacityEndTime | ||
| CapacityNumberOfCapacities | P_CapacityDefinition | CapacityNumberOfCapacities | ||
| CapacityPlanUtilizationPercent | P_CapacityDefinition | CapacityPlanUtilizationPercent | ||
| fltpendasTotOperatingDurationInHours | ||||
| fltpendasCapacityOperatingDuration |
@ClientHandling.algorithm: #SESSION_VARIABLE
@AbapCatalog.sqlViewName: 'PWRKCTRAVAILCAP'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck:#NOT_REQUIRED
@VDM.viewType: #COMPOSITE
@VDM.private: true
define view P_WorkCenterAvailableCapacity
as select from I_WorkCenterCapacity as WorkCenterCapacity
inner join P_CapacityDefinition as CapacityPerShift on WorkCenterCapacity.CapacityInternalID = CapacityPerShift.CapacityInternalID
inner join P_WrkCtrWorkDays as WorkDays on
// WorkDays.WorkCenterInternalID = CapacityPerShift.WorkCenterInternalID
// and WorkDays.WorkCenterTypeCode = CapacityPerShift.WorkCenterTypeCode
// and WorkDays.CapacityInternalID = CapacityPerShift.CapacityInternalID
// and WorkDays.CapacityCategoryAllocation = CapacityPerShift.CapacityCategoryAllocation and
WorkDays.FactoryCalendar = CapacityPerShift.FactoryCalendar
and WorkDays.CalendarDate <= CapacityPerShift.ValidityEndDate
// and CapacityPerShift.ValidityBeginDate <> '00000000'
// and CapacityPerShift.ValidityEndDate <> '00000000'
and WorkDays.CalendarDate >= CapacityPerShift.ValidityBeginDate
and (
(
CapacityPerShift.WorkDayRule = ''
and // we are only interested in workdays
WorkDays.workdays = 1
)
or(
CapacityPerShift.WorkDayRule = '1'
)
)
and (
(
CapacityPerShift.AvailableCapacityIntervalDurn = '01'
) // 1 day shift interval duration
or(
CapacityPerShift.AvailableCapacityIntervalDurn = '07'
and // 7 day shift interval duration
WorkDays.WeekDay = CapacityPerShift.WeekDay
)
)
{
key WorkCenterCapacity.WorkCenterInternalID as WorkCenterInternalID,
key WorkCenterCapacity.WorkCenterTypeCode as WorkCenterTypeCode,
key WorkCenterCapacity.CapacityCategoryAllocation,
key WorkCenterCapacity.CapacityInternalID,
//key coalesce( CapacityPerShift.CapacityActiveVersion, '00') as CapacityActiveVersion,
key CapacityPerShift.CapacityActiveVersion as CapacityActiveVersion,
key CapacityPerShift.ValidityEndDate,
key cast( WorkDays.WeekDay as char1) as WeekDay,
key CapacityPerShift.AvailableCapacityShift,
key WorkDays.CalendarDate,
CapacityPerShift.ShiftStartDate,
CapacityPerShift.ShiftStartTime,
CapacityPerShift.ShiftEndDate,
CapacityPerShift.ShiftEndTime,
cast(CapacityPerShift.CapacityBreakDuration as abap.fltp) / cast(3600 as abap.fltp) as CapacityBreakDuration,
cast('H' as unit) as WorkCenterCapacityUnit,
cast('%' as unit) as WorkCenterUtilizationUnit,
CapacityPerShift.ValidityBeginDate,
WorkDays.CalendarMonth,
WorkDays.CalendarYear,
WorkDays.CalendarWeek,
// key WorkDays.CalendarDate,
WorkDays.workdays,
// WorkDays.WorkCenter,
CapacityPerShift.Plant as WorkCenterPlant,
CapacityPerShift.CapacityCategoryCode,
// case when (CapacityPerShift.ShiftName = '' and CapacityPerShift.AvailableCapacityShift <> '') then
// concat('SH ', CapacityPerShift.AvailableCapacityShift)
// else
// CapacityPerShift.ShiftName
// end
// as ShiftName,
case when (CapacityPerShift.ShiftName = '' and CapacityPerShift.AvailableCapacityShift <> '')
then concat('SH ', CapacityPerShift.AvailableCapacityShift)
when ((CapacityPerShift.ShiftName <> '')
or (CapacityPerShift.ShiftName = '' and CapacityPerShift.AvailableCapacityShift = ''))
then CapacityPerShift.ShiftName
end as ShiftName,
CapacityPerShift.ShiftDefinition,
CapacityPerShift.ShiftGrouping,
CapacityPerShift.WorkDayRule,
CapacityPerShift.FactoryCalendar,
// case
// when WorkDays.WorkDays = 0 and CapacityPerShift.WorkDayRule = '' or
// CapacityPerShift.WorkDayRule = '0' or
// CapacityPerShift.CapacityEndTime = CapacityPerShift.CapacityStartTime or
// CapacityPerShift.OperatingDurationInSeconds = 0
// then 0
// else
// CapacityPerShift.OperatingDurationInSeconds
// end
// as OperatingDurationInSeconds,
//
// case
// when WorkDays.WorkDays = 0 and CapacityPerShift.WorkDayRule = '' or
// CapacityPerShift.WorkDayRule = '0' or
// CapacityPerShift.CapacityEndTime = CapacityPerShift.CapacityStartTime or
// CapacityPerShift.OperatingDurationInSeconds = 0
// then 0
// else
// CapacityPerShift.TotOperatingDurationInSeconds
// end as TotOperatingDurationInSeconds,
CapacityPerShift.CapacityStartTime,
CapacityPerShift.CapacityEndTime,
CapacityPerShift.CapacityNumberOfCapacities,
CapacityPerShift.CapacityPlanUtilizationPercent,
// case
// when WorkDays.WorkDays = 0 and CapacityPerShift.WorkDayRule = '' or
// CapacityPerShift.WorkDayRule = '0' or
// CapacityPerShift.CapacityEndTime = CapacityPerShift.CapacityStartTime or
// CapacityPerShift.OperatingDurationInSeconds = 0
// then 0
// else
// CapacityPerShift.OperatingDurationInSeconds / cast ( 3600 as abap.fltp )
// end
// as OperatingDurationInHours,
case
when WorkDays.workdays = 0 and CapacityPerShift.WorkDayRule = '' or
CapacityPerShift.WorkDayRule = '0' or
// CapacityPerShift.CapacityEndTime = CapacityPerShift.CapacityStartTime or
CapacityPerShift.OperatingDurationInSeconds = 0
then 0
else
CapacityPerShift.TotOperatingDurationInSeconds / cast ( 3600 as abap.fltp )
end as TotOperatingDurationInHours,
// case
// when WorkDays.WorkDays = 0 and CapacityPerShift.WorkDayRule = '' or
// CapacityPerShift.WorkDayRule = '0' or
// // CapacityPerShift.CapacityEndTime = CapacityPerShift.CapacityStartTime or
// CapacityPerShift.OperatingDurationInSeconds = 0
// then 0
// when WorkDays.WorkDays <> 0 and CapacityPerShift.WorkDayRule <> '' or
// CapacityPerShift.WorkDayRule <> '0' or CapacityPerShift.OperatingDurationInSeconds <> 0
// then CapacityPerShift.TotOperatingDurationInSeconds / cast ( 3600 as abap.fltp )
// end as TotOperatingDurationInHours,
case
when WorkDays.workdays = 0 and CapacityPerShift.WorkDayRule = '' or
CapacityPerShift.WorkDayRule = '0' or
CapacityPerShift.CapacityOperatingDuration = 0
then 0
else
CapacityPerShift.CapacityOperatingDuration / cast ( 3600 as abap.fltp )
end as CapacityOperatingDuration
// case
// when WorkDays.WorkDays = 0 and CapacityPerShift.WorkDayRule = '' or
// CapacityPerShift.WorkDayRule = '0' or
// CapacityPerShift.CapacityOperatingDuration = 0
// then 0
// when WorkDays.WorkDays <> 0 and CapacityPerShift.WorkDayRule <> '' or
// CapacityPerShift.WorkDayRule <> '0' or
// CapacityPerShift.CapacityOperatingDuration <> 0
// then
// CapacityPerShift.CapacityOperatingDuration / cast ( 3600 as abap.fltp )
// end as CapacityOperatingDuration
}
Learn More
- What Is a CDS View in SAP S/4HANA?
- Types of CDS Views: Basic, Composite, Consumption, and Transactional
- SAP Tables vs CDS Views — Key Differences
- Understanding Data Lineage in SAP S/4HANA
- VDM (Virtual Data Model) in SAP S/4HANA Explained
- CDS View Annotations — A Complete Guide
- CDS View Field Mapping and Associations
- Understanding the SAP S/4HANA Data Model
- CDS View Extensions and Custom Fields in SAP S/4HANA
- Released APIs and Stability Contracts in SAP S/4HANA