P_RO_SAFTSLSINVITEMTOTAL

DDL: P_RO_SAFTSLSINVITEMTOTAL Type: view_entity CONSUMPTION Package: GLO_FIN_IS_SAFT_RO

Sales invoice items

P_RO_SAFTSLSINVITEMTOTAL is a Consumption CDS View that provides data about "Sales invoice items" in SAP S/4HANA. It reads from 5 data sources (I_OperationalAcctgDocItem, I_RO_SAFTDocumentTypeMap, P_RO_SAFTInvoiceItemCount, P_RO_SAFTJournalEntryItemExc, P_RO_SAFTOplAcctgDocItmExc) and exposes 13 fields with key fields StatryRptCategory, StatryRptgEntity, StatryRptRunID, SourceLedger, Ledger. Part of development package GLO_FIN_IS_SAFT_RO.

Data Sources (5)

SourceAliasJoin Type
I_OperationalAcctgDocItem Bseg inner
I_RO_SAFTDocumentTypeMap DocType inner
P_RO_SAFTInvoiceItemCount P_RO_SAFTInvoiceItemCount inner
P_RO_SAFTJournalEntryItemExc P_RO_SAFTJournalEntryItemExc inner
P_RO_SAFTOplAcctgDocItmExc P_RO_SAFTOplAcctgDocItmExc inner

Parameters (1)

NameTypeDefault
P_AlternativeGLAccountIsUsed saft_ro_alt_gl_account_flag

Annotations (7)

NameValueLevelField
VDM.viewType #CONSUMPTION view
VDM.private true view
ObjectModel.usageType.serviceQuality #X view
ObjectModel.usageType.sizeCategory #XL view
ObjectModel.usageType.dataClass #MIXED view
AccessControl.personalData.blocking #NOT_REQUIRED view
AccessControl.authorizationCheck #NOT_REQUIRED view

Fields (13)

KeyFieldSource TableSource FieldDescription
KEY StatryRptCategory Log StatryRptCategory
KEY StatryRptgEntity Log StatryRptgEntity
KEY StatryRptRunID Log StatryRptRunID
KEY SourceLedger Acdoca SourceLedger
KEY Ledger Acdoca Ledger
KEY CompanyCode Acdoca CompanyCode
KEY FiscalYear Acdoca FiscalYear
KEY AccountingDocument Acdoca AccountingDocument
KEY LedgerGLLineItem Acdoca LedgerGLLineItem
AccountingDocumentItem Acdoca AccountingDocumentItem
AccountingDocumentType Acdoca AccountingDocumentType
PostingDate Acdoca PostingDate
CompanyCodeCurrency Acdoca CompanyCodeCurrency
@VDM.viewType: #CONSUMPTION
@VDM.private:true
@ObjectModel.usageType.serviceQuality: #X
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.dataClass: #MIXED
@AccessControl.personalData.blocking: #NOT_REQUIRED
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view entity P_RO_SAFTSLSINVITEMTOTAL
  with parameters

    P_AlternativeGLAccountIsUsed : saft_ro_alt_gl_account_flag

  as select distinct from  I_StRpJournalEntryHeaderLog                                                                          as Log

    inner join             P_RO_SAFTJournalEntryItemExc(P_AlternativeGLAccountIsUsed: $parameters.P_AlternativeGLAccountIsUsed) as Acdoca                   on  Acdoca.AccountingDocument = Log.AccountingDocument
                                                                                                                                                            and Acdoca.CompanyCode        = Log.CompanyCode
                                                                                                                                                            and Acdoca.FiscalYear         = Log.FiscalYear

    inner join             I_RO_SAFTDocumentTypeMap                                                                             as DocType                  on  DocType.AccountingDocumentType = Acdoca.AccountingDocumentType
                                                                                                                                                            and DocType.CompanyCode            = Acdoca.CompanyCode

    inner join             I_OperationalAcctgDocItem                                                                            as Bseg                     on  Bseg.AccountingDocument     = Acdoca.AccountingDocument
                                                                                                                                                            and Bseg.CompanyCode            = Acdoca.CompanyCode
                                                                                                                                                            and Bseg.FiscalYear             = Acdoca.FiscalYear
                                                                                                                                                            and Bseg.AccountingDocumentItem = Acdoca.AccountingDocumentItem
                                                                                                                                                            and Bseg.PostingDate            = Acdoca.PostingDate
                                                                                                                                                            and Bseg.AccountingDocumentType = Acdoca.AccountingDocumentType

    inner join             P_RO_SAFTOplAcctgDocItmExc(P_AlternativeGLAccountIsUsed: $parameters.P_AlternativeGLAccountIsUsed)   as BsegV                    on  BsegV.AccountingDocument     = Acdoca.AccountingDocument
                                                                                                                                                            and BsegV.CompanyCode            = Acdoca.CompanyCode
                                                                                                                                                            and BsegV.FiscalYear             = Acdoca.FiscalYear
                                                                                                                                                            and BsegV.PostingDate            = Acdoca.PostingDate
                                                                                                                                                            and BsegV.AccountingDocumentType = Acdoca.AccountingDocumentType


    inner join             P_RO_SAFTInvoiceItemCount(P_AlternativeGLAccountIsUsed: $parameters.P_AlternativeGLAccountIsUsed)    as reporting_country_filter on  reporting_country_filter.AccountingDocument     = Acdoca.AccountingDocument
                                                                                                                                                            and reporting_country_filter.CompanyCode            = Acdoca.CompanyCode
                                                                                                                                                            and reporting_country_filter.FiscalYear             = Acdoca.FiscalYear
                                                                                                                                                            and reporting_country_filter.PostingDate            = Acdoca.PostingDate
                                                                                                                                                            and reporting_country_filter.AccountingDocumentType = Acdoca.AccountingDocumentType
                                                                                                                                                            and reporting_country_filter.TaxType                = 'A'


    left outer to one join I_RO_SAFTSpecialGLIndicator                                                                          as SpecialGLIndicator       on  Acdoca.CompanyCode          = SpecialGLIndicator.CompanyCode
                                                                                                                                                            and Acdoca.FinancialAccountType = SpecialGLIndicator.AccountType
                                                                                                                                                            and Acdoca.SpecialGLCode        = SpecialGLIndicator.SpecialGLCode

    left outer to one join I_RO_SAFTSpecialGLIndicator                                                                          as SpecialGLIndicatorF      on  BsegV.CompanyCode          = SpecialGLIndicatorF.CompanyCode
                                                                                                                                                            and BsegV.FinancialAccountType = SpecialGLIndicatorF.AccountType
                                                                                                                                                            and BsegV.SpecialGLCode        = SpecialGLIndicatorF.SpecialGLCode

{
  key Log.StatryRptCategory,
  key Log.StatryRptgEntity,
  key Log.StatryRptRunID,
  key Acdoca.SourceLedger,
  key Acdoca.Ledger,
  key Acdoca.CompanyCode,
  key Acdoca.FiscalYear,
  key Acdoca.AccountingDocument,
  key Acdoca.LedgerGLLineItem,
      Acdoca.AccountingDocumentItem,
      Acdoca.AccountingDocumentType,
      Acdoca.PostingDate,
      //@Semantics.currencyCode:true

      Acdoca.CompanyCodeCurrency,

      // Negative posting is already considered in P_Acdoca_COM1 and the indicator

      // is also adjusted there accordingly thus there is no need to do it here

      case Acdoca.DebitCreditCode
        when 'H' then 'C'
        else 'D'
      end as DebitCreditCode,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      case when Bseg.OriglTaxBaseAmountInCoCodeCrcy <> 0 then
        case when Bseg.DebitCreditCode = 'H' or (Bseg.DebitCreditCode = 'S' and Bseg.IsNegativePosting = 'X')
          then -1 * abs(Bseg.OriglTaxBaseAmountInCoCodeCrcy)
          else abs(Bseg.OriglTaxBaseAmountInCoCodeCrcy) end
        when Acdoca.DebitCreditCode = 'H' then -1 * Acdoca.AmountInCompanyCodeCurrency
        else Acdoca.AmountInCompanyCodeCurrency
      end as AmountInCompanyCodeCurrency

}
/**
  The same WHERE condition is used in C_RO_SAFTSalesInvoiceItemC and P_RO_SAFTInvoiceItemCount.
  If you adjust it here keep in mind to update in other places as well.
**/
where
       DocType.RO_SAFTSourceDocumentType =  '01'
  and  BsegV.FinancialAccountType        =  'D'
  and
  // exclude customer vendor lines

  (
       Acdoca.FinancialAccountType       <> 'D'
    or Acdoca.SpecialGLCode              =  SpecialGLIndicator.SpecialGLCode
  )
  and(
       Acdoca.FinancialAccountType       <> 'K'
    or Acdoca.SpecialGLCode              =  SpecialGLIndicator.SpecialGLCode
  )
  and
  // exclude VAT lines

       Bseg.AccountingDocumentItemType   <> 'T'
  and  SpecialGLIndicatorF.SpecialGLCode is null