P_ServiceContractDataCalc

DDL: P_SERVICECONTRACTDATACALC Type: view COMPOSITE

P_ServiceContractDataCalc is a Composite CDS View in SAP S/4HANA. It reads from 1 data source (I_ServiceDocumentEnhcd) and exposes 71 fields with key fields ServiceObjectType, ServiceContract. It has 3 associations to related views.

Data Sources (1)

SourceAliasJoin Type
I_ServiceDocumentEnhcd I_ServiceDocumentEnhcd from

Associations (3)

CardinalityTargetAliasCondition
[0..1] I_ServiceDocumentType _ServiceContractType $projection.ServiceContractType = _ServiceContractType.ServiceDocumentType
[0..1] I_ServiceDocumentStatus _ServiceContractStatus $projection.ServiceContractStatus = _ServiceContractStatus.ServiceDocumentStatus
[0..1] I_CalendarDate _CurrentDate _CurrentDate.CalendarDate = $session.system_date

Annotations (10)

NameValueLevelField
ClientHandling.algorithm #SESSION_VARIABLE view
AbapCatalog.sqlViewName PSRVCCONTRCALC view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
VDM.private true view
VDM.viewType #COMPOSITE view
AccessControl.authorizationCheck #NOT_REQUIRED view
ObjectModel.usageType.dataClass #MIXED view
ObjectModel.usageType.serviceQuality #D view
ObjectModel.usageType.sizeCategory #XXL view

Fields (71)

KeyFieldSource TableSource FieldDescription
KEY ServiceObjectType ServiceObjectType
KEY ServiceContract ServiceDocument
ServiceContractUUID ServiceDocumentUUID
ServiceDocumentDescription ServiceDocumentDescription
ServiceDocumentType ServiceDocumentType
ServiceContractType ServiceDocumentType
RefBusinessSolutionOrder RefBusinessSolutionOrder
ServiceDocumentStatus ServiceDocumentStatus
ServiceContractStatus ServiceDocumentStatus
ServiceDocumentIsOpen ServiceDocumentIsOpen
TransactionCurrency TransactionCurrency
PurchaseOrderByCustomer PurchaseOrderByCustomer
SalesOrganization SalesOrganization
DistributionChannel DistributionChannel
Division Division
SalesOffice SalesOffice
SalesGroup SalesGroup
SalesOrganizationOrgUnitID SalesOrganizationOrgUnitID
SalesOfficeOrgUnitID SalesOfficeOrgUnitID
SalesGroupOrgUnitID SalesGroupOrgUnitID
ServiceOrganization ServiceOrganization
SoldToPartyCountry SoldToPartyCountry
SoldToPartyRegion SoldToPartyRegion
SoldToParty SoldToParty
ResponsibleEmployee ResponsibleEmployee
ServiceTeam ServiceTeam
ContactPerson ContactPerson
ShipToParty ShipToParty
ServiceContractStartDate ServiceContractStartDate
ServiceContractEndDate ServiceContractEndDate
ServiceContractStartDateTime ServiceContractStartDateTime
ServiceContractEndDateTime ServiceContractEndDateTime
CalendarDate _CurrentDate CalendarDate
ShiftedCalendarDate
LastDayOfMonthDate
ServiceDocNetAmount ServiceDocNetAmount
int4endasNmbrOfExpiredSrvcContracts
int4endasNmbrOfExpiredSrvcContrCurWeek
int4endasNmbrOfExpiredSrvcContrNextWeek
int4endasNmbrOfExpiredSrvcContrIn2Weeks
int4endasNmbrOfExpiredSrvcContrIn3Weeks
NumberOfDays
_ServiceObjType _ServiceObjType
_ServiceDocumentType _ServiceDocumentType
_ServiceContractType _ServiceContractType
_ServiceDocumentStatus _ServiceDocumentStatus
_SrvcDocLifecycleStatus _SrvcDocLifecycleStatus
_ServiceContractStatus _ServiceContractStatus
_ServiceDocumentIsOpen _ServiceDocumentIsOpen
_SoldToPartyRegion _SoldToPartyRegion
_SoldToPartyCountry _SoldToPartyCountry
_TransactionCurrency _TransactionCurrency
_CurrentDate _CurrentDate
_SoldToParty _SoldToParty
_SalesOrganization _SalesOrganization
_DistributionChannel _DistributionChannel
_Division _Division
_SalesOffice _SalesOffice
_SalesGroup _SalesGroup
_SalesOrganizationOrgUnit _SalesOrganizationOrgUnit
_SalesOfficeOrgUnit _SalesOfficeOrgUnit
_SalesGroupOrgUnit _SalesGroupOrgUnit
_ServiceOrganizationOrgUnit _ServiceOrganizationOrgUnit
_SalesOrganizationOrgUnit_2 _SalesOrganizationOrgUnit_2
_SalesOfficeOrgUnit_2 _SalesOfficeOrgUnit_2
_SalesGroupOrgUnit_2 _SalesGroupOrgUnit_2
_ServiceOrganizationOrgUnit_2 _ServiceOrganizationOrgUnit_2
_RespEmployee _RespEmployee
_ServiceTeam _ServiceTeam
_ContactPerson _ContactPerson
_ShipToParty _ShipToParty
@ClientHandling.algorithm: #SESSION_VARIABLE
@AbapCatalog: {
  sqlViewName: 'PSRVCCONTRCALC',
  compiler.compareFilter: true,
  preserveKey: true
}
@VDM: {
   private:true,
   viewType: #COMPOSITE
}
@AccessControl: {
  authorizationCheck: #NOT_REQUIRED,
  personalData.blocking: #('TRANSACTIONAL_DATA')
}
@ObjectModel: {
   usageType: {
     dataClass:      #MIXED,
     serviceQuality: #D,
     sizeCategory:   #XXL
   }
}
//@Analytics: {

//   dataCategory: #CUBE,

//   internalName: #LOCAL

//   }

//@Metadata.allowExtensions:true

//@Metadata.ignorePropagatedAnnotations: true


define view P_ServiceContractDataCalc
  as select from I_ServiceDocumentEnhcd

  association [0..1] to I_ServiceDocumentType   as _ServiceContractType   on $projection.ServiceContractType = _ServiceContractType.ServiceDocumentType
  association [0..1] to I_ServiceDocumentStatus as _ServiceContractStatus on $projection.ServiceContractStatus = _ServiceContractStatus.ServiceDocumentStatus
  association [0..1] to I_CalendarDate          as _CurrentDate           on _CurrentDate.CalendarDate = $session.system_date
{
       @ObjectModel.foreignKey.association: '_ServiceObjType'
  key  ServiceObjectType,
  key  ServiceDocument                                                    as ServiceContract,
       ServiceDocumentUUID                                                as ServiceContractUUID,
       ServiceDocumentDescription,
       @ObjectModel.foreignKey.association: '_ServiceDocumentType'
       ServiceDocumentType,
       @ObjectModel.foreignKey.association: '_ServiceContractType'
       ServiceDocumentType                                                as ServiceContractType,
       RefBusinessSolutionOrder,

       @ObjectModel.foreignKey.association: '_SrvcDocLifecycleStatus'
       ServiceDocumentStatus,
       @ObjectModel.foreignKey.association: '_ServiceContractStatus'
       ServiceDocumentStatus                                              as ServiceContractStatus,

       @ObjectModel.foreignKey.association: '_ServiceDocumentIsOpen'
       ServiceDocumentIsOpen,

       @ObjectModel.foreignKey.association: '_TransactionCurrency'
       @Semantics.currencyCode:true
       TransactionCurrency,

       PurchaseOrderByCustomer,
       @ObjectModel.foreignKey.association: '_SalesOrganization'
       SalesOrganization,
       @ObjectModel.foreignKey.association: '_DistributionChannel'
       DistributionChannel,
       @ObjectModel.foreignKey.association: '_Division'
       Division,
       @ObjectModel.foreignKey.association: '_SalesOffice'
       SalesOffice,
       @ObjectModel.foreignKey.association: '_SalesGroup'
       SalesGroup,
       //       @ObjectModel.foreignKey.association: '_SalesOrganizationOrgUnit'

       @ObjectModel.foreignKey.association: '_SalesOrganizationOrgUnit_2'
       SalesOrganizationOrgUnitID,
       //       @ObjectModel.foreignKey.association: '_SalesOfficeOrgUnit'

       @ObjectModel.foreignKey.association: '_SalesOfficeOrgUnit_2'
       SalesOfficeOrgUnitID,
       //       @ObjectModel.foreignKey.association: '_SalesGroupOrgUnit'

       @ObjectModel.foreignKey.association: '_SalesGroupOrgUnit_2'
       SalesGroupOrgUnitID,
       //       @ObjectModel.foreignKey.association: '_ServiceOrganizationOrgUnit'

       @ObjectModel.foreignKey.association: '_ServiceOrganizationOrgUnit_2'
       ServiceOrganization,

       @ObjectModel.foreignKey.association: '_SoldToPartyCountry'
       SoldToPartyCountry,
       @ObjectModel.foreignKey.association: '_SoldToPartyRegion'
       SoldToPartyRegion,
       SoldToParty,
       @ObjectModel.foreignKey.association: '_RespEmployee'
       ResponsibleEmployee,
       @ObjectModel.foreignKey.association: '_ServiceTeam'
       ServiceTeam,
       @ObjectModel.foreignKey.association: '_ContactPerson'
       ContactPerson,
       @ObjectModel.foreignKey.association: '_ShipToParty'
       ShipToParty,

       ServiceContractStartDate,
       ServiceContractEndDate,
       ServiceContractStartDateTime,
       ServiceContractEndDateTime,
       _CurrentDate.CalendarDate,
       dats_add_months( _CurrentDate.CalendarDate, -6, 'FAIL')            as ShiftedCalendarDate,

       dats_add_days( _CurrentDate.FirstDayOfMonthDate,  -1, 'FAIL')      as LastDayOfMonthDate,

       @Semantics.amount.currencyCode: 'TransactionCurrency'
       @DefaultAggregation: #SUM
       ServiceDocNetAmount,

       @DefaultAggregation: #SUM
       case when ServiceContractEndDate < $session.system_date then cast (1 as abap.int4)
       end                                                                as NmbrOfExpiredSrvcContracts,

       @DefaultAggregation: #SUM
       case when ServiceContractEndDate >= $session.system_date
             and ServiceContractEndDate <= dats_add_days( _CurrentDate.FirstDayOfWeekDate,6,'FAIL')
        then cast (1 as abap.int4)
        end                                                               as NmbrOfExpiredSrvcContrCurWeek,

       @DefaultAggregation: #SUM
       case when ServiceContractEndDate >= dats_add_days( _CurrentDate.FirstDayOfWeekDate,7,'FAIL')
             and ServiceContractEndDate <= dats_add_days( _CurrentDate.FirstDayOfWeekDate,13,'FAIL')
        then cast (1 as abap.int4)
        end                                                               as NmbrOfExpiredSrvcContrNextWeek,

       @DefaultAggregation: #SUM
       case when ServiceContractEndDate >= dats_add_days( _CurrentDate.FirstDayOfWeekDate,14,'FAIL')
             and ServiceContractEndDate <= dats_add_days( _CurrentDate.FirstDayOfWeekDate,20,'FAIL')
        then cast (1 as abap.int4)
        end                                                               as NmbrOfExpiredSrvcContrIn2Weeks,

       @DefaultAggregation: #SUM
       case when ServiceContractEndDate >= dats_add_days( _CurrentDate.FirstDayOfWeekDate,21,'FAIL')
             and ServiceContractEndDate <= dats_add_days( _CurrentDate.FirstDayOfWeekDate,27,'FAIL')
        then cast (1 as abap.int4)
        end                                                               as NmbrOfExpiredSrvcContrIn3Weeks,


       case
       //           when ServiceContractEndDate < $session.system_date then 'SC01'


           when ServiceContractEndDate >= $session.system_date and
                ServiceContractEndDate <= dats_add_days( _CurrentDate.FirstDayOfWeekDate,6,'FAIL')
            then 'SC02'

           when ServiceContractEndDate >= dats_add_days( _CurrentDate.FirstDayOfWeekDate,7,'FAIL') and
                ServiceContractEndDate <= dats_add_days( _CurrentDate.FirstDayOfWeekDate,13,'FAIL')
            then 'SC03'

           when ServiceContractEndDate >= dats_add_days( _CurrentDate.FirstDayOfWeekDate,14,'FAIL') and
                ServiceContractEndDate <= dats_add_days( _CurrentDate.FirstDayOfWeekDate,20,'FAIL')
            then 'SC04'

           when ServiceContractEndDate >= dats_add_days( _CurrentDate.FirstDayOfWeekDate,21,'FAIL') and
                ServiceContractEndDate <= dats_add_days( _CurrentDate.FirstDayOfWeekDate,27,'FAIL')
            then 'SC05'
            end                                                           as IsExpired,

       dats_days_between(ServiceContractStartDate,ServiceContractEndDate) as NumberOfDays,

       _ServiceObjType,
       _ServiceDocumentType,
       _ServiceContractType,
      @API.element.releaseState: #DEPRECATED
      @API.element.successor: '_SrvcDocLifecycleStatus'
      _ServiceDocumentStatus,
      _SrvcDocLifecycleStatus,
       _ServiceContractStatus,
       _ServiceDocumentIsOpen,
       _SoldToPartyRegion,
       _SoldToPartyCountry,
       _TransactionCurrency,
       _CurrentDate,
       _SoldToParty,
       _SalesOrganization,
       _DistributionChannel,
       _Division,
       _SalesOffice,
       _SalesGroup,

       @API.element.releaseState: #DEPRECATED
       @API.element.successor: '_SalesOrganizationOrgUnit_2'
       _SalesOrganizationOrgUnit,
       @API.element.releaseState: #DEPRECATED
       @API.element.successor: '_SalesOfficeOrgUnit_2'
       _SalesOfficeOrgUnit,
       @API.element.releaseState: #DEPRECATED
       @API.element.successor: '_SalesGroupOrgUnit_2'
       _SalesGroupOrgUnit,
       @API.element.releaseState: #DEPRECATED
       @API.element.successor: '_ServiceOrganizationOrgUnit_2'
       _ServiceOrganizationOrgUnit,

       _SalesOrganizationOrgUnit_2,
       _SalesOfficeOrgUnit_2,
       _SalesGroupOrgUnit_2,
       _ServiceOrganizationOrgUnit_2,

       _RespEmployee,
       _ServiceTeam,
       _ContactPerson,
       _ShipToParty


}
where
      ServiceObjectType           = 'BUS2000112'
  and ServiceContractEndDate      is not initial
  //  and ServiceDocumentIsOpen  = 'X'

  and ServiceDocumentIsQuotation != 'X'
  and ServiceDocumentTemplateType is initial
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_CALENDARDATE",
"I_SERVICEDOCUMENTENHCD"
],
"ASSOCIATED":
[
"I_BUSINESSPARTNER",
"I_CALENDARDATE",
"I_COUNTRY",
"I_CURRENCY",
"I_CUSTMGMTBUSOBJTYPE",
"I_DISTRIBUTIONCHANNEL",
"I_DIVISION",
"I_REGION",
"I_SALESGROUP",
"I_SALESOFFICE",
"I_SALESORGANIZATION",
"I_SALESORGANIZATIONUNIT",
"I_SERVICEDOCOPENSTATUS",
"I_SERVICEDOCUMENTSTATUS",
"I_SERVICEDOCUMENTTYPE",
"I_SRVCDOCLIFECYCLESTATUS",
"I_SRVCMGMTORGANIZATIONUNIT"
],
"BASE":
[
"I_SERVICEDOCUMENTENHCD"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/