P_SPP_PredictionData01

DDL: P_SPP_PREDICTIONDATA01 SQL: PSDSPPPDA01 Type: view COMPOSITE Package: VDM_SD_PREDICTED_SALES

Prediction Data 01

P_SPP_PredictionData01 is a Composite CDS View that provides data about "Prediction Data 01" in SAP S/4HANA. It reads from 2 data sources (I_BillingDocumentItemBasic, P_SPP_PredictionPeriod) and exposes 14 fields with key fields BillingDocument, BillingDocumentItem. Part of development package VDM_SD_PREDICTED_SALES.

Data Sources (2)

SourceAliasJoin Type
I_BillingDocumentItemBasic I_BillingDocumentItemBasic from
P_SPP_PredictionPeriod PP left_outer

Annotations (6)

NameValueLevelField
AbapCatalog.sqlViewName PSDSPPPDA01 view
AbapCatalog.preserveKey true view
AbapCatalog.compiler.compareFilter true view
ClientHandling.algorithm #SESSION_VARIABLE view
VDM.private true view
VDM.viewType #COMPOSITE view

Fields (14)

KeyFieldSource TableSource FieldDescription
KEY BillingDocument BillingDocument
KEY BillingDocumentItem BillingDocumentItem
BillingDocumentDate BillingDocumentDate
SalesOrganization SalesOrganization
DistributionChannel DistributionChannel
Division Division
SoldToParty SoldToParty
CustomerGroup CustomerGroup
Material Material
MaterialGroup MaterialGroup
BillingDocumentType BillingDocumentType
DisplayCurrency
TransactionCurrency TransactionCurrency
NetAmount NetAmount
@AbapCatalog.sqlViewName: 'PSDSPPPDA01'
@AbapCatalog.preserveKey:true
@AbapCatalog.compiler.compareFilter:true
@ClientHandling.algorithm: #SESSION_VARIABLE
@VDM.private: true
@VDM.viewType: #COMPOSITE

define view P_SPP_PredictionData01
as select from I_BillingDocumentItemBasic
left outer join P_SPP_PredictionPeriod as PP
  on PP.CalendarDate = PP.CalendarDate
{
  key BillingDocument,
  key BillingDocumentItem,
  
  BillingDocumentDate,
  
  SalesOrganization,
  DistributionChannel,
  Division,
  SoldToParty,
  CustomerGroup,
  Material,
  MaterialGroup,
  BillingDocumentType,
  
  cast( 'EUR' as vdm_v_display_currency) as DisplayCurrency,
  
  TransactionCurrency,
  NetAmount,
  
  case 
    when( SDDocumentCategory = 'M'
          or SDDocumentCategory = 'P'
          or SDDocumentCategory = 'S'
          or SDDocumentCategory = '5'
        )
    then
      cast( abs( NetAmount) as netwr )
    when( SDDocumentCategory = 'O'
          or SDDocumentCategory = 'N'
          or SDDocumentCategory = '6'
        )
    then
      cast( -1 * abs( NetAmount) as netwr )
  end
  as Amount
}
where StatisticalValueControl = ''
  and BillingDocumentCategory != 'P'
  and BillingDocumentIsTemporary = ''
  and OverallBillingStatus <> 'C'
  and ( SDDocumentCategory = 'M' // Invoice

        or SDDocumentCategory = 'N' // Invoice Canceled

        or SDDocumentCategory = 'O' // Credit Memo

        or SDDocumentCategory = 'P' // Debit Memo

        or SDDocumentCategory = 'S' // Credit Memo Canceled

        or SDDocumentCategory = 'U' // Pro Forma Invoice

        or SDDocumentCategory = '5' // Intercompany Invoice

        or SDDocumentCategory = '6' // Intercompany Credit Memo

      )
  and BillingDocumentDate >= PP.PredictionStartDate1
  and BillingDocumentDate < PP.PredictionEndDate
  and NetAmount != 0
  and NetAmount is not null