P_RblsItmForKeyDtePerd2_WSJ

DDL: P_RBLSITMFORKEYDTEPERD2_WSJ SQL: PRBLSKDATDUE2WSJ Type: view COMPOSITE

P_RblsItmForKeyDtePerd2_WSJ is a Composite CDS View in SAP S/4HANA. It reads from 1 data source (P_RblsItmForKeyDteDuePerd1) and exposes 31 fields with key fields CompanyCode, AccountingDocument, AccountingDocumentItem, FiscalYear.

Data Sources (1)

SourceAliasJoin Type
P_RblsItmForKeyDteDuePerd1 P_RblsItmForKeyDteDuePerd1 from

Parameters (2)

NameTypeDefault
P_KeyDate sydate
P_PeriodType fis_period_type

Annotations (7)

NameValueLevelField
AbapCatalog.sqlViewName PRBLSKDATDUE2WSJ view
AbapCatalog.preserveKey true view
AbapCatalog.compiler.compareFilter true view
VDM.viewType #COMPOSITE view
VDM.private true view
AccessControl.authorizationCheck #NOT_REQUIRED view
ClientHandling.algorithm #SESSION_VARIABLE view

Fields (31)

KeyFieldSource TableSource FieldDescription
KEY CompanyCode OpenReceivables CompanyCode
KEY AccountingDocument OpenReceivables AccountingDocument
KEY AccountingDocumentItem OpenReceivables AccountingDocumentItem
KEY FiscalYear OpenReceivables FiscalYear
InvoiceReference OpenReceivables InvoiceReference
InvoiceItemReference OpenReceivables InvoiceItemReference
InvoiceReferenceFiscalYear OpenReceivables InvoiceReferenceFiscalYear
ClearingDate OpenReceivables ClearingDate
PostingDate OpenReceivables PostingDate
DocumentDate OpenReceivables DocumentDate
FinancialAccountType OpenReceivables FinancialAccountType
DebitCreditCode OpenReceivables DebitCreditCode
Customer OpenReceivables Customer
FollowOnDocumentType OpenReceivables FollowOnDocumentType
SpecialGLCode OpenReceivables SpecialGLCode
GLAccount OpenReceivables GLAccount
DisplayCurrency OpenReceivables CompanyCodeCurrency
CompanyCodeCurrency OpenReceivables CompanyCodeCurrency
AmountInCompanyCodeCurrency OpenReceivables AmountInCompanyCodeCurrency
ReportingPeriodStartDate OpenReceivables ReportingPeriodStartDate
ReportingPeriodEndDate OpenReceivables ReportingPeriodEndDate
RefInvcDocumentDate ReferencedInvoices DocumentDate
RefInvcFinancialAccountType ReferencedInvoices FinancialAccountType
RefInvcDebitCreditCode ReferencedInvoices DebitCreditCode
RefInvcNetPaymentDays ReferencedInvoices NetPaymentDays
RefInvcCashDiscount2Days ReferencedInvoices CashDiscount2Days
RefInvcCashDiscount1Days ReferencedInvoices CashDiscount1Days
RefInvcDueCalculationBaseDate ReferencedInvoices DueCalculationBaseDate
RefInvcInvoiceReference ReferencedInvoices InvoiceReference
RefInvcNetDueDate ReferencedInvoices NetDueDate
NetDueDateendasNetDueDate
@AbapCatalog.sqlViewName: 'PRBLSKDATDUE2WSJ'
@AbapCatalog.preserveKey:true 
@AbapCatalog.compiler.compareFilter:true 
@VDM.viewType: #COMPOSITE
@VDM.private:true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ClientHandling.algorithm: #SESSION_VARIABLE

define view P_RblsItmForKeyDtePerd2_WSJ
  with parameters
    P_KeyDate : sydate,
    P_PeriodType               : fis_period_type
    
    as select from P_RblsItmForKeyDteDuePerd1( P_KeyDate: :P_KeyDate,
                                            P_PeriodType: :P_PeriodType ) as OpenReceivables
    left outer to one join I_OperationalAcctgDocItem as ReferencedInvoices on  OpenReceivables.CompanyCode                = ReferencedInvoices.CompanyCode
                                                                   and OpenReceivables.InvoiceReference           = ReferencedInvoices.AccountingDocument
                                                                   and OpenReceivables.InvoiceItemReference       = ReferencedInvoices.AccountingDocumentItem
                                                                   and OpenReceivables.InvoiceReferenceFiscalYear = ReferencedInvoices.FiscalYear
                                                                   and OpenReceivables.FinancialAccountType       = ReferencedInvoices.FinancialAccountType
                                                                   and OpenReceivables.AccountingDocumentCategory = ReferencedInvoices.AccountingDocumentCategory
                                                                   and ReferencedInvoices.FinancialAccountType = 'D'      

{
  key OpenReceivables.CompanyCode                                    as CompanyCode,
  key OpenReceivables.AccountingDocument                             as AccountingDocument,
  key OpenReceivables.AccountingDocumentItem                         as AccountingDocumentItem,
  key OpenReceivables.FiscalYear                                     as FiscalYear,

      OpenReceivables.InvoiceReference                               as InvoiceReference,
      OpenReceivables.InvoiceItemReference                           as InvoiceItemReference,
      OpenReceivables.InvoiceReferenceFiscalYear                     as InvoiceReferenceFiscalYear,
      OpenReceivables.ClearingDate                                   as ClearingDate,
      OpenReceivables.PostingDate                                    as PostingDate,
      OpenReceivables.DocumentDate                                   as DocumentDate,
      OpenReceivables.FinancialAccountType                           as FinancialAccountType,
      OpenReceivables.DebitCreditCode                                as DebitCreditCode,
      OpenReceivables.Customer                                       as Customer,
      OpenReceivables.FollowOnDocumentType                           as FollowOnDocumentType,
      OpenReceivables.SpecialGLCode                                  as SpecialGLCode,
      OpenReceivables.GLAccount                                      as GLAccount,
      OpenReceivables.CompanyCodeCurrency                            as DisplayCurrency,
      OpenReceivables.CompanyCodeCurrency                            as CompanyCodeCurrency,
      OpenReceivables.AmountInCompanyCodeCurrency                    as AmountInCompanyCodeCurrency,
      OpenReceivables.ReportingPeriodStartDate ,
      OpenReceivables.ReportingPeriodEndDate,

      ReferencedInvoices.DocumentDate                                as RefInvcDocumentDate,
      ReferencedInvoices.FinancialAccountType                        as RefInvcFinancialAccountType,
      ReferencedInvoices.DebitCreditCode                             as RefInvcDebitCreditCode,
      ReferencedInvoices.NetPaymentDays                              as RefInvcNetPaymentDays,
      ReferencedInvoices.CashDiscount2Days                           as RefInvcCashDiscount2Days,
      ReferencedInvoices.CashDiscount1Days                           as RefInvcCashDiscount1Days,
      ReferencedInvoices.DueCalculationBaseDate                      as RefInvcDueCalculationBaseDate,
      ReferencedInvoices.InvoiceReference                            as RefInvcInvoiceReference,
      ReferencedInvoices.NetDueDate                                  as RefInvcNetDueDate,

      case
// unltimate safety net: relevant reference which is not valid (e.g. down payment referencing to a (statistical) down payment request; DPR not selected due to join condition)

// - in case of performance issues one may replace the calculation by another branch caring for relevant, but invalid references (see AR grid based on ACDOCA where the calculation

//   yielded to a high runtime due higher data volume of ACDOCA compared to BSEG; there another branch was introduced w/o calculation of net due date for relevant but invalid references)  

        when ReferencedInvoices.NetDueDate is null or ReferencedInvoices.NetDueDate is initial
          then OpenReceivables.NetDueDate
        else                                            
          ReferencedInvoices.NetDueDate  
      end                                                            as NetDueDate  
}
where     OpenReceivables.FollowOnDocumentType <> ''
      and OpenReceivables.FollowOnDocumentType <> 'V'
      and OpenReceivables.FollowOnDocumentType <> 'P'
      and OpenReceivables.InvoiceReference     <> 'V'  // V is a valid invoice reference value for credit memos via e.g. transaction FB75 (see documentation of DTEL REBZG)

      and (
              OpenReceivables.InvoiceReference <> ''
           or OpenReceivables.InvoiceItemReference <> '000'  // it is required to specify an invoice item reference (also for join) in contrast to documentation of DTEL REBZZ

           or OpenReceivables.InvoiceReferenceFiscalYear <> '0000'
          )
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_OPERATIONALACCTGDOCITEM",
"P_RBLSITMFORKEYDTEDUEPERD1"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/