@AbapCatalog.sqlViewName: 'PSTODLVPERFANA'
@ClientHandling.algorithm: #SESSION_VARIABLE
@AbapCatalog.compiler.compareFilter: true
@VDM.private: true
@VDM.viewType: #COMPOSITE
@AccessControl.authorizationCheck: #CHECK
define view P_STOItmDelivAnlyts
//Delivery Document to STO Doc
as select from I_DeliveryDocumentItem as DelItm
{
key DelItm.ReferenceSDDocument,
key cast(right(ReferenceSDDocumentItem,5) as vdm_stocktransportorderitem) as ReferenceSDDocumentItem,
DelItm.ReferenceSDDocumentCategory,
//dimensions
_DeliveryDocument.ShippingPoint as DelivShpPoint,
_DeliveryDocument._ShippingPoint,
_DeliveryDocument.DeliveryDocumentType,
_DeliveryDocument._DeliveryDocumentType,
_DeliveryDocument.DeliveryPriority as DelivPrio,
_DeliveryDocument._DeliveryPriority,
_DeliveryDocument.ShippingCondition as DelivShpCondt,
_DeliveryDocument._ShippingCondition,
_DeliveryDocument.Warehouse,
_DeliveryDocument._Warehouse,
_DeliveryDocument.TransportationGroup as DelivTransGroup,
_DeliveryDocument._TransportationGroup,
_DeliveryDocument.ProposedDeliveryRoute as DeliveryRoute,
_DeliveryDocument._ProposedDeliveryRoute as _DeliveryRoute,
// //measures
// max (
// case when ProofOfDeliveryRelevanceCode != ''
// and ProofOfDeliveryStatus = 'C'
// then DelItm._DeliveryDocument.ProofOfDeliveryDate
// else dats_add_days(
// DelItm._DeliveryDocument.DeliveryDate, --- delivery date adjusted by planned/actual deviation of GI
// dats_days_between (DelItm._DeliveryDocument.PlannedGoodsIssueDate, DelItm._DeliveryDocument.ActualGoodsMovementDate),
// 'UNCHANGED' )
// end )
// as LatestDeliveryDate,
// max(DelItm._DeliveryDocument.ActualGoodsMovementDate) as LatestActlGodsMvtDate,
// shipping
max (
case when ProofOfDeliveryRelevanceCode != ''
and ProofOfDeliveryStatus = 'C'
then DelItm._DeliveryDocument.ProofOfDeliveryDate
else
case when DelItm._DeliveryDocument.OverallGoodsMovementStatus != 'C'
then dats_add_days(
DelItm._DeliveryDocument.DeliveryDate, --- delivery date adjusted by GI overdue days
div ((dats_days_between (DelItm._DeliveryDocument.PlannedGoodsIssueDate, cast($session.system_date as dats) )
+ Abs(dats_days_between (DelItm._DeliveryDocument.PlannedGoodsIssueDate, cast($session.system_date as dats) ))),2),
'UNCHANGED' )
else
dats_add_days(
DelItm._DeliveryDocument.DeliveryDate, --- delivery date adjusted by planned/actual deviation of GI
dats_days_between (DelItm._DeliveryDocument.PlannedGoodsIssueDate, DelItm._DeliveryDocument.ActualGoodsMovementDate),
'UNCHANGED' )
end
end
)
as LatestDeliveryDate,
max (
case when DelItm._DeliveryDocument.OverallGoodsMovementStatus != 'C'
then dats_add_days(
DelItm._DeliveryDocument.PlannedGoodsIssueDate, --- (expected) actual goods movement date adjusted by GI overdue days
div ((dats_days_between (DelItm._DeliveryDocument.PlannedGoodsIssueDate, cast($session.system_date as dats) )
+ Abs(dats_days_between (DelItm._DeliveryDocument.PlannedGoodsIssueDate, cast($session.system_date as dats) ))),2),
'UNCHANGED' )
else
DelItm._DeliveryDocument.ActualGoodsMovementDate
end
)
as LatestActlGodsMvtDate,
max(DelItm._DeliveryDocument.PlannedGoodsIssueDate) as LatestPlndGodsMvtDate
}
where
ReferenceSDDocumentCategory = 'V' and
_DeliveryDocument.SDDocumentCategory <> '7' //exlude inbound deliveries
group by
ReferenceSDDocument,
ReferenceSDDocumentItem,
ReferenceSDDocumentCategory,
_DeliveryDocument.ShippingPoint,
_DeliveryDocument.DeliveryDocumentType,
_DeliveryDocument.DeliveryPriority,
_DeliveryDocument.ShippingCondition,
_DeliveryDocument.Warehouse,
_DeliveryDocument.TransportationGroup,
_DeliveryDocument.ProposedDeliveryRoute
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_DELIVERYDOCUMENT",
"I_DELIVERYDOCUMENTITEM"
],
"ASSOCIATED":
[
"I_DELIVERYDOCUMENTTYPE",
"I_DELIVERYPRIORITY",
"I_ROUTE",
"I_SHIPPINGCONDITION",
"I_SHIPPINGPOINT",
"I_TRANSPORTATIONGROUP",
"I_WAREHOUSE"
],
"BASE":
[
"I_DELIVERYDOCUMENT"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/