@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: 'PSODUEDATEREUS21'
/*
.........Description "SO/notYetDelivered":...............
To a given SalesOrder the possible DueDate is selected from min(DeliveryDocumentDate):
first choice: from related confirmed open SLs or
second choice: related requested SLs.
third choice: If both choices are missing, the RequestedDeliveryDate is taken.
The calculated attribute DueDate contains the final choice.
Result:
SO (SalesOrg,Distibution,Division) with DueDate
Note: in case a given sales order ABC has both a billing and a delivery block formulated as user status,
there are two entries to this sales order ABC in this model. However this is unproblematic, since in all
use scenarios it is ensured in the reusing interface models that only one entry is selected during runtime.
Note: In contrast to variant „same name but without 2“ this one does not include the user status. By this static complexity is reused.
*/
define view P_SlsOrdNotDelivdDueDte2
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'
left outer to many join I_SalesDocumentScheduleLine as ConfirmedSL --to get first preference of DueDate
on SOH.SalesDocument = ConfirmedSL.SalesDocument
and ConfirmedSL.IsConfirmedDelivSchedLine = 'X'
and ( ConfirmedSL.OpenConfdDelivQtyInOrdQtyUnit > 0 or ConfirmedSL.DelivBlockReasonForSchedLine != '' ) --Reason: DelBlock on SL temporarily sets OpenQuan to zero
left outer to many join I_SalesDocumentScheduleLine as RequestedSL --to get second preference of DueDate
on SOH.SalesDocument = RequestedSL.SalesDocument
and RequestedSL.IsRequestedDelivSchedLine = 'X'
and ( RequestedSL.OpenReqdDelivQtyInOrdQtyUnit > 0 or RequestedSL.DelivBlockReasonForSchedLine != '' ) --Reason: DelBlock on SL temporarily sets OpenQuan to zero
{
//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( case when ConfirmedSL.DeliveryCreationDate > '00000000'
then ConfirmedSL.DeliveryCreationDate
else
case when RequestedSL.DeliveryCreationDate > '00000000'
then RequestedSL.DeliveryCreationDate
else SOH.RequestedDeliveryDate
end
end
)
as DueDate,
//Status
SOH.OverallDeliveryBlockStatus,
SOH.OverallBillingBlockStatus,
SOH.DeliveryBlockReason, --needed for DeliveryBlock
SOH.HeaderBillingBlockReason, --needed for BillingBlock
SOH.OverallTotalDeliveryStatus, --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 -- all "sales order like" categories/vbtyps (also enforced further up in the model stack, but also here for Performance reasons)
SOH.SDDocumentCategory = 'C' or
SOH.SDDocumentCategory = 'I' or
SOH.SDDocumentCategory = 'L'
group by
SOH.SalesDocument,
SOH.SalesOrganization,
SOH.DistributionChannel,
SOH.OrganizationDivision,
SOH.SalesDocumentType,
SOH.OverallSDProcessStatus,
SOH.SalesDocumentDate,
SOH.SalesGroup,
SOH.SalesOffice,
SOH.SoldToParty,
--SOH.PurchaseOrderByCustomer,
--VBKD.PurchaseOrderByCustomer,
SOH.RequestedDeliveryDate,
SOH.OverallDeliveryBlockStatus,
SOH.OverallBillingBlockStatus,
SOH.DeliveryBlockReason,
SOH.HeaderBillingBlockReason,
SOH.OverallTotalDeliveryStatus,
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_SALESDOCUMENTSCHEDULELINE"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/