P_RSHWCHeaderCapacityDefinitio

DDL: P_RSHWCHEADERCAPACITYDEFINITIO SQL: PRSHWCHEADCAPDEF Type: view CONSUMPTION

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

Data Sources (2)

SourceAliasJoin Type
I_Capacity Capacity from
I_RSHAssignedWorkCenters user_var inner

Annotations (6)

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

Fields (14)

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

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

Name:                       Work Center Header Capacity Definition
Specification:              The view is to calculate the opening hours without break of the work center
                            so this can be used in the higher views to calculate the capacity from header
Requires:                   NA
Ensures:                    Work Center Header Capacity without breaks is returned for all assigned work centers.
                            Factory Calendar is derived from Capacity resp. Plant.
Owners:                     CK
Contributors:               AN
Unit Test required Y/N:     Yes
Additional comments         None

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

define view P_RSHWCHeaderCapacityDefinitio

  as select from I_Capacity               as Capacity

    inner join   I_RSHAssignedWorkCenters as user_var on user_var.CapacityInternalID = Capacity.CapacityInternalID

{
  key Capacity.CapacityInternalID                                       as CapacityInternalID,
      user_var.WorkCenterInternalID                                     as WorkCenterInternalID,
      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,

      user_var.WorkCenter                                               as WorkCenter,
      user_var.WorkCenterCategoryCode                                   as WorkCenterCategoryCode,
      user_var.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_RSHASSIGNEDWORKCENTERS"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/