@EndUserText.label: 'Utilities Contract'
//@VDM.viewType: #COMPOSITE
@AccessControl.authorizationCheck: #MANDATORY
//Begin of BOPF
@ObjectModel.modelCategory: #BUSINESS_OBJECT
@VDM.viewType:#TRANSACTIONAL
//End of BOPF
@ObjectModel.usageType.dataClass: #TRANSACTIONAL
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.sizeCategory: #XL
@AccessControl.personalData.blocking: #REQUIRED
@AccessControl.privilegedAssociations: ['_User']
@VDM.lifecycle.contract.type: #SAP_INTERNAL_API
@ObjectModel.sapObjectNodeType.name: 'UtilitiesContract'
define root view entity I_UtilitiesContractTP
as select from I_UtilitiesContract as UtilitiesContract
inner join I_UtilitiesInstallationHist as UtilitiesInstallationHist on UtilitiesInstallationHist.UtilitiesInstallation = UtilitiesContract.UtilitiesInstallation
and UtilitiesInstallationHist.UtilsInstHistValidityEndDate >= UtilitiesContract.UtilitiesMoveOutDate
and UtilitiesInstallationHist.UtilsInstHistValidityStartDate <= UtilitiesContract.UtilitiesMoveOutDate
inner join I_ContractAccountPartner as ContractAccountPartner on ContractAccountPartner.ContractAccount = UtilitiesContract.ContractAccount
association [1..1] to I_ContractAccountHeader as _ContractAccountHeader on $projection.ContractAccount = _ContractAccountHeader.ContractAccount
association [0..1] to I_CABusinessLock as _CABusinessLock on $projection.UtilitiesContract = _CABusinessLock.CABusinessLockObject
and _CABusinessLock.CABusinessLockValidFrom <= $projection.UtilitiesMoveInDate
and _CABusinessLock.CABusinessLockValidTo >= $projection.UtilitiesMoveInDate
and _CABusinessLock.CABusinessLockObjectCategory = '41'
/*Cardinality should be 0..1, but due to ATC checks set to 0..n */
association [0..*] to I_UtilsInstIntAndExtPtOfDeliv as _UtilsInstIntAndExtPtOfDeliv on $projection.UtilitiesInstallation = _UtilsInstIntAndExtPtOfDeliv.UtilitiesInstallation
and _UtilsInstIntAndExtPtOfDeliv.UtilsPoDAllocValidityEndDate = '99991231'
and _UtilsInstIntAndExtPtOfDeliv.UtilsPoDAllocValidityEndTime = '235959'
association [0..1] to I_LatestUtilsBillgOrdForContr as _LatestUtilsBillgOrdForContr on $projection.UtilitiesContract = _LatestUtilsBillgOrdForContr.UtilitiesContract
association [0..1] to I_LtstUtilsContrBillgBlkRsnChg as _LtstUtilsContrBillgBlkRsnChg on $projection.UtilitiesContract = _LtstUtilsContrBillgBlkRsnChg.ChangeDocObject
association [0..1] to I_LtstUtilsBillgDateForContr as _LtstUtilsBillgDateForContr on $projection.UtilitiesContract = _LtstUtilsBillgDateForContr.UtilitiesContract
association [0..1] to I_UtilitiesPortion as _UtilitiesPortion on $projection.utilitiesportion = _UtilitiesPortion.UtilitiesPortion
association [0..1] to I_UtilitiesPortion as _AlternativeUtilitiesPortion on $projection.AlternativeUtilitiesPortion = _AlternativeUtilitiesPortion.UtilitiesPortion
association [0..1] to I_UtilitiesPortion as _LastUtilitiesPortion on $projection.LastUtilitiesPortion = _LastUtilitiesPortion.UtilitiesPortion
//Interim Solution because of performance problems: access with timestamp (31.12.9999, 23:59) instead of move out date
// and (
// (
// $projection.UtilitiesMoveOutDate < _UtilsInstIntAndExtPtOfDeliv.UtilsPoDAllocValidityEndDate and
// $projection.UtilitiesMoveOutDate >= _UtilsInstIntAndExtPtOfDeliv.UtilsPoDAllocValidityStartDate
// ) or
// (
// $projection.UtilitiesMoveOutDate = _UtilsInstIntAndExtPtOfDeliv.UtilsPoDAllocValidityEndDate and
// _UtilsInstIntAndExtPtOfDeliv.UtilsPoDAllocValidityEndTime ='235959'
// )
//)
{
key UtilitiesContract.UtilitiesContract,
@ObjectModel.foreignKey.association: '_UtilitiesInstallation'
key UtilitiesContract.UtilitiesInstallation,
@ObjectModel.foreignKey.association: '_BusinessPartner'
@ObjectModel.text.element: [ 'BusinessPartnerName' ]
key ContractAccountPartner.BusinessPartner,
key UtilitiesInstallationHist.UtilsInstHistValidityEndDate,
key _UtilsInstIntAndExtPtOfDeliv.UtilsInternalPointOfDelivery,
@ObjectModel.foreignKey.association: '_CompanyCode'
UtilitiesContract.CompanyCode,
@ObjectModel.foreignKey.association: '_Division'
UtilitiesContract.UtilitiesDivision,
@ObjectModel.foreignKey.association:'_AlternativeUtilitiesPortion'
UtilitiesContract.AlternativeUtilitiesPortion,
UtilitiesContract.UtilsContrIsBilledManually,
@ObjectModel.foreignKey.association: '_UtilsBillgBlockReason'
UtilitiesContract.UtilsBillgBlockReason,
@ObjectModel.foreignKey.association:'_UtilsBillgUnblockReason'
UtilitiesContract.UtilsBillgUnblockReason,
// @ObjectModel.foreignKey.association: '_UtilitiesInstallation'
// UtilitiesContract.UtilitiesInstallation,
@ObjectModel.foreignKey.association: '_ContractAccountHeader'
UtilitiesContract.ContractAccount,
UtilitiesContract.UtilitiesMoveInDate,
UtilitiesContract.UtilitiesMoveOutDate,
UtilitiesContract.UtilsContrIsFinallyBilled,
@ObjectModel.foreignKey.association: '_UtilsPlantOrCompanyCnsmpn'
UtilitiesContract.UtilsPlantOrCompanyConsumption,
@ObjectModel.foreignKey.association: '_InvcUtilsContractsJointly'
UtilitiesContract.UtilsContrJointInvcType,
UtilitiesContract.UtilitiesContractCanclnDate,
UtilitiesContract.UtilitiesContractRenewalDate,
@ObjectModel.foreignKey.association: '_CADunningProcedure'
UtilitiesContract.CADunningProcedure,
@ObjectModel.foreignKey.association: '_UtilitiesServiceProvider'
UtilitiesContract.UtilitiesServiceProvider,
@ObjectModel.foreignKey.association: '_UtilsContrProcessingStatus'
UtilitiesContract.UtilsContractProcessingSts,
UtilitiesContract.AuthorizationGroup,
UtilitiesContract.DeletionIndicator,
@ObjectModel.foreignKey.association: '_UtilsOutsrtgChkGrpBillg'
UtilitiesContract.UtilsOutsrtgCheckGrpForBillg,
UtilitiesContract.UtilitiesContractDescription,
@ObjectModel.foreignKey.association: '_UtilsAccountDetnCode'
UtilitiesContract.UtilitiesAccountDetnCode,
@ObjectModel.foreignKey.association: '_UtilsContrSpcfcBdgtBillgCyc'
UtilitiesContract.UtilsContrSpcfcBdgtBillgCycle,
@ObjectModel.foreignKey.association: '_UtilsBillgOutsortingGroup'
UtilitiesContract.UtilsBillgOutsortingReason,
// Due to the performance reasons the calculation for the field UtilitiesReason that is used in the Block Contracts app as a filter should not be done.
// This leads to full table scans and causes huge CPU time and memory consumption
@ObjectModel.foreignKey.association:'_UtilitiesPortion'
UtilitiesInstallationHist._MeterReadingUnit.UtilitiesPortion,
// case
// when UtilitiesContract.AlternativeUtilitiesPortion = ' '
// then cast(UtilitiesInstallationHist._MeterReadingUnit.UtilitiesPortion as portion preserving type)
// when UtilitiesContract.AlternativeUtilitiesPortion <> ' '
// then cast(UtilitiesContract.AlternativeUtilitiesPortion as portion preserving type)
// end as UtilitiesPortion,
@ObjectModel.foreignKey.association: '_UtilsBillingClass'
UtilitiesInstallationHist.UtilitiesBillingClass,
@ObjectModel.foreignKey.association: '_MeterReadingUnit'
UtilitiesInstallationHist.MeterReadingUnit,
@ObjectModel.foreignKey.association: '_UtilitiesRateCategory'
UtilitiesInstallationHist.UtilitiesRateCategory,
@ObjectModel.foreignKey.association: '_ContractAccountCategory'
cast(ContractAccountPartner._ContrAcc.ContractAccountCategory as e_vktyp_vdm preserving type) as ContractAccountCategory,
@ObjectModel.foreignKey.association: '_ApplArea'
ContractAccountPartner._ContrAcc.CAApplicationArea,
cast(ContractAccountPartner.CAAlternativeInvoiceRecipient as e_altinvrec_vdm preserving type ) as CAAlternativeInvoiceRecipient,
ContractAccountPartner._RelshpOfBP.CABPIsAccountHolder,
ContractAccountPartner._BusinessPartner.BusinessPartnerName,
/* Billing Order Data */
case
when _LatestUtilsBillgOrdForContr.UtilitiesContract is not null
then cast( 'X' as e_bilgorderexists_vdm preserving type )
when _LatestUtilsBillgOrdForContr.UtilitiesContract is null
then cast( '' as e_bilgorderexists_vdm preserving type )
end as UtilsBillgOrderIsExisting,
@ObjectModel.foreignKey.association:'_LastUtilitiesPortion'
UtilitiesContract.LastUtilitiesPortion,
@ObjectModel.foreignKey.association: '_User'
@ObjectModel.text.element: [ 'UserDescription' ]
_LtstUtilsContrBillgBlkRsnChg._UtilsContrBillgBlkRsnChgs.CreatedByUser,
_LtstUtilsContrBillgBlkRsnChg._UtilsContrBillgBlkRsnChgs._User.UserDescription,
_LtstUtilsContrBillgBlkRsnChg._UtilsContrBillgBlkRsnChgs.CreationDate,
/* Billing Document Data */
_LtstUtilsBillgDateForContr._UtilsBillgDocForContract.UtilitiesBillingDocument,
// @Semantics.businessDate.to: true
_LtstUtilsBillgDateForContr.UtilsBillgPeriodEndDate,
// @Semantics.businessDate.from: true
_LtstUtilsBillgDateForContr._UtilsBillgDocForContract.UtilsBillgPeriodStartDate,
@Semantics.systemDate.createdAt: true
_LtstUtilsBillgDateForContr._UtilsBillgDocForContract.UtilsBillgDocCreationDate,
// _UtilsInstIntAndExtPtOfDeliv.UtilsInternalPointOfDelivery,
_UtilsInstIntAndExtPtOfDeliv.UtilsExternalPointOfDelivery,
/* Associations */
UtilitiesContract._Division,
UtilitiesContract._CompanyCode,
UtilitiesContract._UtilsBillgBlockReason,
UtilitiesContract._UtilsBillgUnblockReason,
_UtilitiesPortion,
_AlternativeUtilitiesPortion,
UtilitiesContract._UtilitiesInstallation,
UtilitiesContract._UtilsOutsrtgChkGrpBillg,
UtilitiesContract._UtilsContrSpcfcBdgtBillgCyc,
UtilitiesContract._UtilsAccountDetnCode,
UtilitiesContract._UtilsPlantOrCompanyCnsmpn,
UtilitiesContract._InvcUtilsContractsJointly,
UtilitiesContract._CADunningProcedure,
UtilitiesContract._UtilsContrProcessingStatus,
UtilitiesContract._UtilitiesServiceProvider,
UtilitiesContract._UtilsBillgOutsortingGroup,
_ContractAccountHeader,
ContractAccountPartner._ContrAcc._ApplArea,
_CABusinessLock,
_UtilsInstIntAndExtPtOfDeliv,
UtilitiesInstallationHist._UtilitiesRateCategory,
UtilitiesInstallationHist._UtilsBillingClass,
UtilitiesInstallationHist._MeterReadingUnit,
@Consumption.filter.hidden: true
ContractAccountPartner._BusinessPartner,
ContractAccountPartner._ContrAcc._Category as _ContractAccountCategory,
ContractAccountPartner._AltvInvoiceRecipient,
_LatestUtilsBillgOrdForContr,
_LtstUtilsBillgDateForContr,
_LtstUtilsContrBillgBlkRsnChg,
_LtstUtilsContrBillgBlkRsnChg._UtilsContrBillgBlkRsnChgs._User as _User,
_LastUtilitiesPortion
}
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_BUSINESSPARTNER",
"I_CONTRACCTPRTNRELSHPTYPE",
"I_CONTRACTACCOUNTHEADER",
"I_CONTRACTACCOUNTPARTNER",
"I_LATESTUTILSBILLGORDFORCONTR",
"I_LTSTUTILSBILLGDATEFORCONTR",
"I_LTSTUTILSCONTRBILLGBLKRSNCHG",
"I_METERREADINGUNIT",
"I_USER",
"I_UTILITIESCONTRACT",
"I_UTILITIESINSTALLATIONHIST",
"I_UTILSBILLGDOCFORCONTRACT",
"I_UTILSCONTRBILLGBLKRSNCHGS",
"I_UTILSINSTINTANDEXTPTOFDELIV"
],
"ASSOCIATED":
[
"I_BUSINESSPARTNER",
"I_CAAPPLICATIONAREA",
"I_CABUSINESSLOCK",
"I_CADUNNINGPROCEDURE",
"I_COMPANYCODE",
"I_CONTRACTACCOUNTCATEGORY",
"I_CONTRACTACCOUNTHEADER",
"I_DIVISION",
"I_INVCUTILSCONTRACTSJOINTLY",
"I_LATESTUTILSBILLGORDFORCONTR",
"I_LTSTUTILSBILLGDATEFORCONTR",
"I_LTSTUTILSCONTRBILLGBLKRSNCHG",
"I_METERREADINGUNIT",
"I_USER",
"I_UTILITIESINSTALLATION",
"I_UTILITIESPORTION",
"I_UTILITIESRATECATEGORY",
"I_UTILITIESSERVICEPROVIDER",
"I_UTILSACCOUNTDETNCODE",
"I_UTILSBILLGBLOCKREASON",
"I_UTILSBILLGOUTSORTINGGROUP",
"I_UTILSBILLGUNBLOCKREASON",
"I_UTILSBILLINGCLASS",
"I_UTILSCONTRPROCESSINGSTATUS",
"I_UTILSCONTRSPCFCBDGTBILLGCYC",
"I_UTILSINSTINTANDEXTPTOFDELIV",
"I_UTILSOUTSRTGCHKGRPBILLG",
"I_UTILSPLANTORCOMPANYCNSMPN"
],
"BASE":
[
"I_CONTRACTACCOUNTHEADER",
"I_CONTRACTACCOUNTPARTNER",
"I_UTILITIESCONTRACT",
"I_UTILITIESINSTALLATIONHIST",
"I_UTILSCONTRBILLGBLKRSNCHGS"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/