P_RSHWCHeaderCapacity_Cache

DDL: P_RSHWCHEADERCAPACITY_CACHE SQL: PRSHWCHDCAPCACHE Type: view CONSUMPTION

P_RSHWCHeaderCapacity_Cache is a Consumption CDS View in SAP S/4HANA. It reads from 2 data sources (I_WorkCenter, I_Capacity) and exposes 16 fields with key field CapacityInternalID.

Data Sources (2)

SourceAliasJoin Type
I_WorkCenter _WorkCenter inner
I_Capacity Capacity from

Annotations (7)

NameValueLevelField
AbapCatalog.sqlViewName PRSHWCHDCAPCACHE view
AbapCatalog.compiler.compareFilter true view
AccessControl.authorizationCheck #NOT_REQUIRED view
VDM.private true view
VDM.viewType #CONSUMPTION view
ClientHandling.algorithm #SESSION_VARIABLE view
AbapCatalog.preserveKey true view

Fields (16)

KeyFieldSource TableSource FieldDescription
KEY CapacityInternalID I_Capacity CapacityInternalID
WorkCenterInternalID I_WorkCenter WorkCenterInternalID
ValidityBeginDate
ValidityEndDate
CapacityStartTime I_Capacity CapacityStartTime
CapacityEndTime I_Capacity CapacityEndTime
CapacityNumberOfCapacities I_Capacity CapacityNumberOfCapacities
CapacityPlanUtilizationPercent I_Capacity CapacityPlanUtilizationPercent
CapacityBreakDuration I_Capacity CapacityBreakDuration
WorkCenter I_WorkCenter WorkCenter
WorkCenterCategoryCode I_WorkCenter WorkCenterCategoryCode
WorkCenterTypeCode I_WorkCenter WorkCenterTypeCode
Plant I_Capacity Plant
FactoryCalendarendasFactoryCalendar
ShiftGroup I_Capacity ShiftGroup
CapacityActiveVersion I_Capacity CapacityActiveVersion
@AbapCatalog.sqlViewName: 'PRSHWCHDCAPCACHE'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.private: true
@VDM.viewType: #CONSUMPTION
@ClientHandling.algorithm: #SESSION_VARIABLE
@AbapCatalog.preserveKey: true

/*
CONTRACT**********************************************************************************************************************

Name:                       Work Center Header Capacity
Specification:              The view is to get Header capacity of the workcenter from capacity screen(header)
                            and not from the Shifts and Intervals
Requires:                   NA
Ensures:                    Work Center Header Capacity is returned for assigned work centers.
                            Header validity is always 00.00.0000 to 31.12.9999.
                            Capacity and SingleCapacity are calculated considering the break duration, number of capacities and
                            planned utilization percentage.
Owners:                     CK
Contributors:               AN
Unit Test required Y/N:     Yes
Additional comments         None

END OF CONTRACT***************************************************************************************************************
*/

define view P_RSHWCHeaderCapacity_Cache

  as select from I_Capacity   as Capacity

    inner join   I_WorkCenter as _WorkCenter on _WorkCenter.CapacityInternalID = Capacity.CapacityInternalID

{
  key Capacity.CapacityInternalID             as CapacityInternalID,
      _WorkCenter.WorkCenterInternalID        as WorkCenterInternalID,
      cast('00000000' as dats)                as ValidityBeginDate,
      cast('99991231' as dats)                as ValidityEndDate,
      Capacity.CapacityStartTime              as CapacityStartTime,
      Capacity.CapacityEndTime                as CapacityEndTime,

      Capacity.CapacityNumberOfCapacities     as CapacityNumberOfCapacities,
      Capacity.CapacityPlanUtilizationPercent as CapacityPlanUtilizationPercent,
      Capacity.CapacityBreakDuration          as CapacityBreakDuration,

      // Pass maximum opening hours

      case when CapacityEndTime > CapacityStartTime or CapacityStartTime = 0                               // change here!!!!

      // Normal shift, operating duration without break

        then CapacityEndTime - CapacityStartTime
      // Night shift, add 24 hours

        else CapacityEndTime - CapacityStartTime + (24*3600)
      end                                     as OperatingDurationWithoutBreak,

      _WorkCenter.WorkCenter                  as WorkCenter,
      _WorkCenter.WorkCenterCategoryCode      as WorkCenterCategoryCode,
      _WorkCenter.WorkCenterTypeCode          as WorkCenterTypeCode,
      Capacity.Plant                          as Plant,

      //    Derive the factory calendar. Fall back to factory calandar of plant,

      //    if factory calendar at work center level is not maintained

      case when Capacity.FactoryCalendar = ''
           then Capacity._Plant.FactoryCalendar
           else Capacity.FactoryCalendar end  as FactoryCalendar,

      Capacity.ShiftGroup                     as ShiftGroup,
      Capacity.CapacityActiveVersion          as CapacityActiveVersion

}
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_CAPACITY",
"I_PLANT",
"I_WORKCENTER"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/