@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: 'PSODUEDATEREUSE5'
/*
DOCUMENTATION (29.9.2014 by AT, 4.3.2015 DE03 added by AT):
---------------------------------
P_SalesOrderInDelivDueDate encapsulates the due date logic (and the basic fields like
SalesOrder, SalesOrganization, ...) for issue types DE01, DE05, DE03 and IN02.
For issue types DE01 and DE05 the due date is provided via field DueDate.
For issue types IN02 the due date is provided via field BillingDocumentDate.
The consuming cds views (that are the issue models for DE01, DE05, DE03 and IN02) typically cover a issue specific filtering (based
on the status fields below). Furthermore they'll add some formal attributes like issue or issue category.
DueDate logic (added 16.2.2015 by AT):
- considered fields are
TransportationPlanningStatus, TransportationPlanningDate,
OverallPickingStatus, PickingDate,
PlannedGoodsIssueDate
- in case one of TransportationPlanning or Picking is open, the Date corresponding to the open status is chosen
- in case of both of TransportationPlanning or Picking is open, the smallest date of both is chosen
- in case of both of TransportationPlanning or Picking are completed/irrelevant, the PlannedGoodsIssueDate is chosen
Note (added 27.9.2019 by AT)
- P_SalesOrderInDelivDueDate and the analogon on item level (P_SalesOrderInDeliv_ITM_DueDate) are very similar and differ only in some status that are used on item or hdr
respectively. So, now also all item status are added to P_SalesOrderInDelivDueDate.
- with that enhanced P_SalesOrderInDelivDueDate, (1) we can cope w/o P_SalesOrderInDeliv_ITM_DueDate at all AND
(2) we can omit the union construction in DE03 (and DE01).
(3) we obtain a complexity reduction of 5 (10)
*/
define view P_SalesOrderInDelivDueDate
as select from I_DeliveryDocument as DDH
inner join I_DeliveryDocumentItem as DDI on
DDH.DeliveryDocument = DDI.DeliveryDocument
and --AT29.06.2020 enforce underlying/preceding Sales Document is C,I,L
( DDI.ReferenceSDDocumentCategory = 'C' or
DDI.ReferenceSDDocumentCategory = 'I' or
DDI.ReferenceSDDocumentCategory = 'L' )
inner join I_SalesDocumentBasic as SOH on
DDI.ReferenceSDDocument = SOH.SalesDocument
and --AT29.06.2020 enforce underlying/preceding Sales Document is C,I,L
( SOH.SDDocumentCategory = 'C' or
SOH.SDDocumentCategory = 'I' or
SOH.SDDocumentCategory = 'L' )
// left outer to one join P_SalesDocumentBusinessData as VBKD on SOH.SalesDocument = VBKD.SlsDocBusinessData
// and VBKD.SlsDocBusinessDataItem = '000000'
{
//Key
key SOH.SalesDocument as SalesOrder,
key DDI.DeliveryDocument,
key DDI.DeliveryDocumentItem,
//Organization
SOH.SalesOrganization,
SOH.DistributionChannel,
SOH.OrganizationDivision,
SOH.SalesDocumentType,
//Misc
SOH.RequestedDeliveryDate,
SOH.OverallSDProcessStatus,
SOH.SalesDocumentDate,
SOH.SalesGroup,
SOH.SalesOffice,
SOH.SoldToParty,
// VBKD.PurchaseOrderByCustomer,
//Status&Reasons
DDH.DeliveryBlockReason,
DDH.OverallGoodsMovementStatus,
DDI.GoodsMovementStatus ,
DDH.OverallDelivReltdBillgStatus,
DDH.TotalCreditCheckStatus,
DDH.HdrGeneralIncompletionStatus,
DDH.HeaderDelivIncompletionStatus,
DDH.HdrGoodsMvtIncompletionStatus,
DDH.HeaderPackingIncompletionSts,
DDH.HeaderPickgIncompletionStatus,
DDI.ItemGeneralIncompletionStatus, --AT27.9.2019 added see description above
DDI.ItemBillingIncompletionStatus, --AT27.9.2019 added see description above
DDI.ItemPackingIncompletionStatus, --AT27.9.2019 added see description above
DDI.ItemPickingIncompletionStatus, --AT27.9.2019 added see description above
DDI.ItemDeliveryIncompletionStatus, --AT27.9.2019 added see description above
DDI.ItemGdsMvtIncompletionSts, --AT27.9.2019 added see description above
DDH.OverallChmlCmplncStatus, --AT27.9.2019 still used in DE01, but might be replaced by item states below (14.10.2019: no longer used )
DDH.OverallDangerousGoodsStatus, --AT27.9.2019 still used in DE01, but might be replaced by item states below (14.10.2019: no longer used )
DDH.OverallSafetyDataSheetStatus, --AT27.9.2019 still used in DE01, but might be replaced by item states below (14.10.2019: no longer used )
DDI.ChmlCmplncStatus, --AT14.10.2019 added to support Product Compliance Aspect of DE01 on ITEM Level (instead of on HDR level)
DDI.DangerousGoodsStatus, --AT14.10.2019 added to support Product Compliance Aspect of DE01 on ITEM Level (instead of on HDR level)
DDI.SafetyDataSheetStatus, --AT14.10.2019 added to support Product Compliance Aspect of DE01 on ITEM Level (instead of on HDR level)
DDI.TrdCmplncEmbargoSts, --AT23.9.2019 Trade Compliance Issue DE07 CE2002 --AT27.9.2019 added see description above
DDI.TrdCmplncSnctndListChkSts, --AT23.9.2019 Trade Compliance Issue DE07 CE2002 --AT27.9.2019 added see description above
DDI.TrdCmplncLegalControlSts, --AT23.9.2019 Trade Compliance Issue DE07 CE2002 --AT27.9.2019 added see description above
//Dates
DDH.PlannedGoodsIssueDate,
DDH.BillingDocumentDate,
DDH.OverallPickingStatus,
case when --CASE 1: TPStatus is open, OPStatus is open
( DDH.TransportationPlanningStatus = 'A' or DDH.TransportationPlanningStatus = 'B' ) and
( DDH.OverallPickingStatus = 'A' or DDH.OverallPickingStatus = 'B' )
then
case when
DDH.PickingDate < DDH.TransportationPlanningDate
then DDH.PickingDate
else DDH.TransportationPlanningDate
end
else case when -- CASE 2: TPStatus is open, OPStatus is completed/irrelevant
( DDH.TransportationPlanningStatus = 'A' or DDH.TransportationPlanningStatus = 'B' ) and
( DDH.OverallPickingStatus = 'C' or DDH.OverallPickingStatus = ' ' )
then DDH.TransportationPlanningDate
else case when -- CASE 3: TPStatus is completed/irrelevant, OPStatus is open
( DDH.TransportationPlanningStatus = 'C' or DDH.TransportationPlanningStatus = ' ' ) and
( DDH.OverallPickingStatus = 'A' or DDH.OverallPickingStatus = 'B' )
then DDH.PickingDate
else case when -- CASE 4: TPStatus is completed/irrelevant, OPStatus is completed/irrelevant
( DDH.TransportationPlanningStatus = 'C' or DDH.TransportationPlanningStatus = ' ' ) and
( DDH.OverallPickingStatus = 'C' or DDH.OverallPickingStatus = ' ' )
then DDH.PlannedGoodsIssueDate
end -- of CASE4
end -- of CASE3
end -- of CASE2
end -- of CASE1
as DueDate
}
where DDH.SDDocumentCategory = 'J'
;
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_DELIVERYDOCUMENT",
"I_DELIVERYDOCUMENTITEM",
"I_SALESDOCUMENTBASIC"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/