@ClientHandling.algorithm: #SESSION_VARIABLE
@ObjectModel.usageType.dataClass: #MIXED
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.sizeCategory: #S
@VDM.private: true
@VDM.viewType: #COMPOSITE
@AccessControl.authorizationCheck:#NOT_REQUIRED
@AbapCatalog.sqlViewName: 'PSODUEDATEREU210'
/*
.........Description "SO/order related Billing"...............
Description:
Detects SalesOrders that have order related billing (only WITH billing plan).
The DueDate is the next outstanding BillingDate of fplt.
Note: In contrast to variant „same name but without 2“ this one does not include the user status. By this static complexity is reused.
Schematic selection:
[
VBAK
X (inner)
VBAP ( with FKREL = I or X AND FKSAA = A or B )
X (inner join fplt.fplnr = vbap.fplnr)
FPLT (with fksaf = A,E)
] group on SOH-level
with DueDate = Min(fplt.afdat)
Note1: FKREL: all that have order related billing WITH billing plan
Note2: FKSAA: to ensure that billing is still open
Note3: FKSAF: to ensure that plan item is still open
Result:
SO (SalesOrg,Distibution,Division) with DueDate
*/
define view P_SlsOrdBillingPlanDueDate2
as select from I_SalesDocumentBasic /*I_SalesDocument*/ as SOH --PurchaseOrderByCustomer in VBKD
// left outer to one join P_SalesDocumentBusinessData as VBKD on SOH.SalesDocument = VBKD.SlsDocBusinessData
// and VBKD.SlsDocBusinessDataItem = '000000'
inner join I_SalesDocumentItemBasic /*I_SalesDocumentItem*/ as SOI on SOH.SalesDocument = SOI.SalesDocument
and SOH.SalesOrganization = SOI.SalesOrganization --AT26.7.2023 filter push-down for some prominent filter
and SOH.SoldToParty = SOI.SoldToParty --AT26.7.2023 filter push-down for some prominent filter
// left outer to one join P_SalesDocumentBusinessData as VBKD_ITEM on SOI.SalesDocument = VBKD_ITEM.SlsDocBusinessData
// and SOI.SlsDocBusinessDataItem = VBKD_ITEM.SlsDocBusinessDataItem
inner join I_SDBillingPlanItem /*I_SalesDocItemBillingPlanItem */ as fplt on SOI.BillingPlan = fplt.BillingPlan --AT11.4.2020 Vbap Enhancement:now BilingPlan also on vbap (no need to read vbkd_item)
{ --AT26.7.2023 Use of more "slim" variant I_SDBillingPlanItem to get fplt data
//Key
key SOH.SalesDocument,
//Organization
SOH.SalesOrganization,
SOH.DistributionChannel,
SOH.OrganizationDivision,
SOH.SalesDocumentType,
//Misc
SOH.RequestedDeliveryDate,
SOH.OverallSDProcessStatus,
SOH.SalesDocumentDate,
SOH.SalesGroup,
SOH.SalesOffice,
SOH.SoldToParty,
--SOH.PurchaseOrderByCustomer,
// VBKD.PurchaseOrderByCustomer,
//DueDate
min( fplt.BillingPlanBillingDate ) as DueDate,
--SOH.RequestedDeliveryDate,
//Status
SOH.OverallBillingBlockStatus,
SOH.HeaderBillingBlockReason, --needed for BillingBlock
SOH.OverallTotalDeliveryStatus, --needed for BillingBlock
--SOH.OverallSDProcessStatus, --needed for DeliveryBlock, BillingBlock
SOH.OverallOrdReltdBillgStatus, --needed for BillingBlock, Incompletion
SOH.HdrGeneralIncompletionStatus, --needed for SOIncomplete
SOH.OverallPricingIncompletionSts, --needed for SOIncomplete
SOH.HeaderDelivIncompletionStatus, --needed for SOIncomplete
SOH.HeaderBillgIncompletionStatus, --needed for SOIncomplete
SOH.TotalCreditCheckStatus,
SOH.ControllingObject --AT06.06.2019 CE1908: new lsstk/userstatus logic to minimize F+
}
where
(
SOI.ItemIsBillingRelevant = 'I'
or -- all order related billings (only with billing plan)
SOI.ItemIsBillingRelevant = 'X'
)
and(
SOI.OrderRelatedBillingStatus = 'A'
or -- billing not yet completed (on different levels)
SOI.OrderRelatedBillingStatus = 'B'
)
and(
fplt.BillingPlanRelatedBillgStatus = 'A'
or fplt.BillingPlanRelatedBillgStatus = 'E'
)
and(
SOH.OverallOrdReltdBillgStatus = 'A'
or SOH.OverallOrdReltdBillgStatus = 'B'
)
and ( SOH.SDDocumentCategory = 'C' or
SOH.SDDocumentCategory = 'I' or
SOH.SDDocumentCategory = 'L' )
group by
SOH.SalesDocument,
SOH.SalesOrganization,
SOH.DistributionChannel,
SOH.OrganizationDivision,
SOH.SalesDocumentType,
SOH.RequestedDeliveryDate,
SOH.OverallSDProcessStatus,
SOH.SalesDocumentDate,
SOH.SalesGroup,
SOH.SalesOffice,
SOH.SoldToParty,
--SOH.PurchaseOrderByCustomer,
// VBKD.PurchaseOrderByCustomer,
--SOH.RequestedDeliveryDate,
SOH.OverallBillingBlockStatus,
SOH.HeaderBillingBlockReason,
SOH.OverallTotalDeliveryStatus,
SOH.OverallSDProcessStatus,
SOH.OverallOrdReltdBillgStatus,
SOH.HdrGeneralIncompletionStatus,
SOH.OverallPricingIncompletionSts,
SOH.HeaderDelivIncompletionStatus,
SOH.HeaderBillgIncompletionStatus,
SOH.TotalCreditCheckStatus,
SOH.ControllingObject --AT06.06.2019 CE1908: new lsstk/userstatus logic to minimize F+
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_SALESDOCUMENTBASIC",
"I_SALESDOCUMENTITEMBASIC",
"I_SDBILLINGPLANITEM"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/