P_RO_SAFTPurInvItemAmount

DDL: P_RO_SAFTPURINVITEMAMOUNT Type: view_entity CONSUMPTION Package: GLO_FIN_IS_SAFT_RO

Purchase invoice items

P_RO_SAFTPurInvItemAmount is a Consumption CDS View that provides data about "Purchase invoice items" in SAP S/4HANA. It reads from 7 data sources and exposes 15 fields with key fields StatryRptCategory, StatryRptgEntity, StatryRptRunID, SourceLedger, Ledger. Part of development package GLO_FIN_IS_SAFT_RO.

Data Sources (7)

SourceAliasJoin Type
I_JournalEntry Bkpf inner
I_OperationalAcctgDocItem Bseg inner
I_CompanyCode CompanyCode inner
I_RO_SAFTDocumentTypeMap DocType inner
I_StRpJournalEntryHeaderLog Log from
P_RO_SAFTJournalEntryItemExc P_RO_SAFTJournalEntryItemExc inner
P_RO_SAFTROTAXCODE TaxCountry inner

Parameters (1)

NameTypeDefault
P_AlternativeGLAccountIsUsed saft_ro_alt_gl_account_flag

Annotations (6)

NameValueLevelField
AccessControl.authorizationCheck #NOT_REQUIRED view
VDM.viewType #CONSUMPTION view
VDM.private true view
ObjectModel.usageType.sizeCategory #M view
ObjectModel.usageType.serviceQuality #A view
ObjectModel.usageType.dataClass #TRANSACTIONAL view

Fields (15)

KeyFieldSource TableSource FieldDescription
KEY StatryRptCategory I_StRpJournalEntryHeaderLog StatryRptCategory
KEY StatryRptgEntity I_StRpJournalEntryHeaderLog StatryRptgEntity
KEY StatryRptRunID I_StRpJournalEntryHeaderLog 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
PostingDate Acdoca PostingDate
CompanyCodeCurrency Acdoca CompanyCodeCurrency
TransactionCurrency Acdoca TransactionCurrency
TaxItemGroup I_OperationalAcctgDocItem TaxItemGroup
TaxCode I_OperationalAcctgDocItem TaxCode
DebitCreditCode Acdoca DebitCreditCode
@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.viewType: #CONSUMPTION
@VDM.private:true
@ObjectModel.usageType.sizeCategory: #M
@ObjectModel.usageType.serviceQuality: #A
@ObjectModel.usageType.dataClass: #TRANSACTIONAL
define view entity P_RO_SAFTPurInvItemAmount
  with parameters

    P_AlternativeGLAccountIsUsed : saft_ro_alt_gl_account_flag

  as select from           I_StRpJournalEntryHeaderLog                                                                          as Log

    inner join             I_JournalEntry                                                                                       as Bkpf               on  Bkpf.AccountingDocument = Log.AccountingDocument
                                                                                                                                                      and Bkpf.CompanyCode        = Log.CompanyCode
                                                                                                                                                      and Bkpf.FiscalYear         = Log.FiscalYear

    inner join             I_RO_SAFTDocumentTypeMap                                                                             as DocType            on  DocType.AccountingDocumentType = Bkpf.AccountingDocumentType
                                                                                                                                                      and DocType.CompanyCode            = Log.CompanyCode

    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_OperationalAcctgDocItem                                                                            as Bseg               on  Bseg.AccountingDocument     = Acdoca.AccountingDocument
                                                                                                                                                      and Bseg.CompanyCode            = Acdoca.CompanyCode
                                                                                                                                                      and Bseg.FiscalYear             = Acdoca.FiscalYear
                                                                                                                                                      and Bseg.AccountingDocumentItem = Acdoca.AccountingDocumentItem

    inner join             I_CompanyCode                                                                                        as CompanyCode        on CompanyCode.CompanyCode = Bkpf.CompanyCode

    inner join             P_RO_SAFTROTAXCODE                                                                                   as TaxCountry         on  TaxCountry.CompanyCodeCountry       =  CompanyCode.Country
                                                                                                                                                      and TaxCountry.TargetTaxCode            =  Bseg.TaxCode
                                                                                                                                                      and TaxCountry.TaxRateValidityEndDate   >= Bseg.PostingDate
                                                                                                                                                      and TaxCountry.TaxRateValidityStartDate <= Bseg.PostingDate

    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
{
  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.PostingDate,
      Acdoca.CompanyCodeCurrency,
      Acdoca.TransactionCurrency,
      Bseg.TaxItemGroup,
      Bseg.TaxCode,
      Acdoca.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,

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

}
/**
  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 =  '03'
  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'