I_ProjectBillingElmntDueDate is a Composite CDS View that provides data about "Billing Due Date of Billing Element" in SAP S/4HANA. It reads from 3 data sources (I_ProjectBillingElement, P_ProjectBillingElmntDueDate, I_SalesOrderItem) and exposes 7 fields with key field ProjectBillingElementUUID. It has 1 association to related views.
//@AbapCatalog.sqlViewName: 'IPRJBILLDUEDATE'
//@AbapCatalog.compiler.compareFilter: true//@AbapCatalog.preserveKey: true@AccessControl.authorizationCheck: #CHECK@EndUserText.label: 'Billing Due Date of Billing Element'
@VDM.viewType: #COMPOSITE@ObjectModel.usageType.dataClass: #TRANSACTIONAL@ObjectModel.usageType.serviceQuality: #C@ObjectModel.usageType.sizeCategory: #L//@AccessControl.privilegedAssociations: ['_SlsDocItemBillingPlanDueDate' ]//@AccessControl.personalData.blocking: #BLOCKED_DATA_EXCLUDED//@ClientHandling.algorithm: #SESSION_VARIABLEdefineviewentity I_ProjectBillingElmntDueDate --withparameters P_BillingPlanItemUsage : sdbp_item_usage
asselectfrom I_ProjectBillingElement as ProjectBillingElement
innerjoin I_SalesOrderItem as SalesOrderItem on ProjectBillingElement.BillingWBSElementInternalID = SalesOrderItem.WBSElementInternalID
innerjoin P_ProjectBillingElmntDueDate as ProjectBillingElmntDueDate on SalesOrderItem.BillingPlan = ProjectBillingElmntDueDate.BillingPlan
-- association [0..1] to P_ProjectBillingElmntDueDate as _ProjectBillingElmntDueDate on SalesOrderItem.BillingPlan = _ProjectBillingElmntDueDate.BillingPlan
-- and SalesOrderItem.SalesOrder = _ProjectBillingElmntDueDate.SalesOrder
-- and SalesOrderItem.SalesOrderItem = _ProjectBillingElmntDueDate.SalesOrderItem
{
key ProjectBillingElement.ProjectBillingElementUUID,
ProjectBillingElement.BillingWBSElementInternalID as WBSElementInternalID,
ProjectBillingElmntDueDate.DueBillingDate as DueBillingDate,
SalesOrderItem.BillingPlan,
SalesOrderItem.SalesOrder,
SalesOrderItem.SalesOrderItem
--_EnterpriseProjectElement,
--_SalesOrderItem
}
where ProjectBillingElement.BillingWBSElementInternalID isnot initial
// asselectfrom I_ProjectBillingElement as ProjectBillingElement
// --innerjoin I_EnterpriseProjectElement as EnterpriseProjectElement on ProjectBillingElement.BillingWBSElementInternalID = EnterpriseProjectElement.WBSElementInternalID
// innerjoin I_SalesOrderItem as SalesOrderItem on ProjectBillingElement.BillingWBSElementInternalID = SalesOrderItem.WBSElement
// association [0..1] to P_ProjBillingElmntMaxBillDate as _maxbillingduedate on SalesOrderItem.BillingPlan = _maxbillingduedate.BillingPlan
// association [0..1] to P_ProjBillingElmntMinBillDate as _minbillingduedate on SalesOrderItem.BillingPlan = _minbillingduedate.BillingPlan
// --association [1..1] to I_EnterpriseProjectElement as _EnterpriseProjectElement on EnterpriseProjectElement.ProjectElementUUID = _EnterpriseProjectElement.ProjectElementUUID
// --association [1..1] to I_SalesOrderItem as _SalesOrderItem on SalesOrderItem.SalesOrder = _SalesOrderItem.SalesOrder
// -- and SalesOrderItem.SalesOrderItem = _SalesOrderItem.SalesOrderItem
//{
// key ProjectBillingElement.ProjectBillingElementUUID,
// ProjectBillingElement.BillingWBSElementInternalID as WBSElementInternalID,
// --EnterpriseProjectElement.ProjectElementUUID,
// casewhen _maxbillingduedate.MaxDate isnotnullthen _maxbillingduedate.MaxDate
// when _minbillingduedate.MinDate isnotnullthen _minbillingduedate.MinDate
// when _maxbillingduedate.MaxDate isnulland _minbillingduedate.MinDate isnullthen SalesOrderItem.BOMExplosionDate
// --else EnterpriseProjectElement.PlannedEndDate
// endas DueBillingDate,
// SalesOrderItem.BillingPlan,
// SalesOrderItem.SalesOrder,
// SalesOrderItem.SalesOrderItem
// --_EnterpriseProjectElement,
// --_SalesOrderItem
//}
--where
-- EnterpriseProjectElement.WBSElementIsBillingElement = 'X'
// asselectfrom I_SalesOrderItem as SalesOrderItem
// innerjoin I_SalesDocItemBillingPlan as SalesDocItemBillPlan on SalesOrderItem.BillingPlan = SalesDocItemBillPlan.BillingPlan
// --association [0..1] to P_ProjBillingElmntBillgDate as _billingduedate on $projection.BillingPlan = _billingduedate.BillingPlan
// association [1..1] to P_ProjBillingElmntMaxBillDate as _maxbillingduedate on $projection.BillingPlan = _maxbillingduedate.BillingPlan
// association [0..1] to P_ProjBillingElmntMinBillDate as _minbillingduedate on $projection.BillingPlan = _minbillingduedate.BillingPlan
//// asselectfrom I_SlsDocItemBillingPlan as _salesDocItemDueDate
//// association [0..1] to I_SlsDocItemBillingPlanDueDate as _SlsDocItemBillingPlanDueDate on $projection.BillingPlan = _SlsDocItemBillingPlanDueDate.BillingPlan
//// association [1..1] to P_ProjBillingElmntMaxBillDate as _maxbillingduedate on _salesDocItemDueDate.BillingPlan = _maxbillingduedate.BillingPlan
//// association [0..1] to P_ProjBillingElmntMinBillDate as _minbillingduedate on _salesDocItemDueDate.BillingPlan = _minbillingduedate.BillingPlan
//{
// keycast(SalesOrderItem.WBSElement as ps_s4_pspnr preserving type ) as WBSElementInternalID,
// SalesOrderItem.SalesOrder,
// SalesOrderItem.SalesOrderItem,
// SalesDocItemBillPlan.BillingPlan as BillingPlan,
//// COALESCE(_maxbillingduedate(P_BillingPlanItemUsage: :P_BillingPlanItemUsage).MaxDate,
//// _minbillingduedate(P_BillingPlanItemUsage: :P_BillingPlanItemUsage).MinDate ) as DueBillingDate
// case// when _maxbillingduedate.MaxDate isnotnull// thencast(_maxbillingduedate.MaxDate as fkdat)
// when _minbillingduedate.MinDate isnotnull// thencast(_minbillingduedate.MinDate as fkdat)
// -- YD perf optimization - avoid "non null preserving" case {
// -- elsecast ('00000000' as fkdat) //incase there is no open DueBillingDate - for C_ProjectBillingRequestItemTP "where condition" work correctly
// -- }
// endas DueBillingDate
// --min( _billingduedate(P_BillingPlanItemUsage: $parameters.P_BillingPlanItemUsage).BillingDate ) as DueBillingDate
//}
//--groupby SalesOrderItem.WBSElement, SalesOrderItem.SalesOrder, SalesOrderItem.SalesOrderItem, SalesDocItemBillPlan.BillingPlan
//
//// key _salesDocItemDueDate.BillingPlan,
//// _salesDocItemDueDate.BillingPlanUsageCategory,
//
// // _maxbillingduedate.MaxDate as DueBillingDate
// // _SlsDocItemBillingPlanDueDate.BillingPlanItemUsage,
//
//// case//// when _maxbillingduedate(P_BillingPlanItemUsage: :P_BillingPlanItemUsage).MaxDate isnotnull // and _minbillingduedate.MinDate isnotnull//// thencast(_maxbillingduedate(P_BillingPlanItemUsage: :P_BillingPlanItemUsage).MaxDate as fkdat)
//// when _minbillingduedate(P_BillingPlanItemUsage: :P_BillingPlanItemUsage).MinDate isnotnull // and _maxbillingduedate.MaxDate isnull//// thencast(_minbillingduedate(P_BillingPlanItemUsage: :P_BillingPlanItemUsage).MinDate as fkdat)
//// when _maxbillingduedate.MaxDate isnotnulland _minbillingduedate.MinDate isnull//// thencast(_maxbillingduedate.MaxDate as fkdat)
//// elsecast ('00000000' as fkdat)
//// endas DueBillingDate
////}
////groupby _SalesOrderItem.WBSElement, _SalesDocItemBillPlan.BillingPlan,
//// _maxbillingduedate(P_BillingPlanItemUsage: :P_BillingPlanItemUsage).MaxDate,
//// _minbillingduedate(P_BillingPlanItemUsage: :P_BillingPlanItemUsage).MinDate
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_PROJECTBILLINGELEMENT",
"I_SALESORDERITEM",
"P_PROJECTBILLINGELMNTDUEDATE"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/