P_STOItmDelivAnlyts

DDL: P_STOITMDELIVANLYTS SQL: PSTODLVPERFANA Type: view COMPOSITE

P_STOItmDelivAnlyts is a Composite CDS View in SAP S/4HANA. It reads from 1 data source (I_DeliveryDocumentItem) and exposes 18 fields with key fields ReferenceSDDocument, ReferenceSDDocumentItem.

Data Sources (1)

SourceAliasJoin Type
I_DeliveryDocumentItem DelItm from

Annotations (6)

NameValueLevelField
AbapCatalog.sqlViewName PSTODLVPERFANA view
ClientHandling.algorithm #SESSION_VARIABLE view
AbapCatalog.compiler.compareFilter true view
VDM.private true view
VDM.viewType #COMPOSITE view
AccessControl.authorizationCheck #CHECK view

Fields (18)

KeyFieldSource TableSource FieldDescription
KEY ReferenceSDDocument I_DeliveryDocumentItem ReferenceSDDocument
KEY ReferenceSDDocumentItem
ReferenceSDDocumentCategory I_DeliveryDocumentItem ReferenceSDDocumentCategory
DelivShpPoint _DeliveryDocument ShippingPoint
_ShippingPoint _DeliveryDocument _ShippingPoint
DeliveryDocumentType _DeliveryDocument DeliveryDocumentType
_DeliveryDocumentType _DeliveryDocument _DeliveryDocumentType
DelivPrio _DeliveryDocument DeliveryPriority
_DeliveryPriority _DeliveryDocument _DeliveryPriority
DelivShpCondt _DeliveryDocument ShippingCondition
_ShippingCondition _DeliveryDocument _ShippingCondition
Warehouse _DeliveryDocument Warehouse
_Warehouse _DeliveryDocument _Warehouse
DelivTransGroup _DeliveryDocument TransportationGroup
_TransportationGroup _DeliveryDocument _TransportationGroup
DeliveryRoute _DeliveryDocument ProposedDeliveryRoute
_DeliveryRoute _DeliveryDocument _ProposedDeliveryRoute
LatestPlndGodsMvtDate
@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":""
}
}*/