P_RO_SAFTInvoiceItemCount

DDL: P_RO_SAFTINVOICEITEMCOUNT SQL: PROSAFTINVITMCNT Type: view CONSUMPTION Package: GLO_FIN_IS_SAFT_RO

FI Document Relevant for Sales/Purchase Invoice Section

P_RO_SAFTInvoiceItemCount is a Consumption CDS View that provides data about "FI Document Relevant for Sales/Purchase Invoice Section" in SAP S/4HANA. It reads from 3 data sources (P_RO_SAFTOplAcctgDocItmExc, I_TaxCode, P_RO_SAFTROTAXCODE) and exposes 6 fields with key fields CompanyCode, FiscalYear, AccountingDocument. Part of development package GLO_FIN_IS_SAFT_RO.

Data Sources (3)

SourceAliasJoin Type
P_RO_SAFTOplAcctgDocItmExc P_RO_SAFTOplAcctgDocItmExc from
I_TaxCode taxcode inner
P_RO_SAFTROTAXCODE TaxCountry inner

Parameters (1)

NameTypeDefault
P_AlternativeGLAccountIsUsed saft_ro_alt_gl_account_flag

Annotations (10)

NameValueLevelField
AbapCatalog.sqlViewName PROSAFTINVITMCNT view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
AccessControl.authorizationCheck #NOT_REQUIRED view
VDM.viewType #CONSUMPTION view
VDM.private true view
ObjectModel.usageType.sizeCategory #XL view
ObjectModel.usageType.serviceQuality #A view
ObjectModel.usageType.dataClass #TRANSACTIONAL view
ClientHandling.algorithm #SESSION_VARIABLE view

Fields (6)

KeyFieldSource TableSource FieldDescription
KEY CompanyCode Bseg CompanyCode
KEY FiscalYear Bseg FiscalYear
KEY AccountingDocument Bseg AccountingDocument
PostingDate Bseg PostingDate
AccountingDocumentType Bseg AccountingDocumentType
TaxType I_TaxCode TaxType
@AbapCatalog.sqlViewName: 'PROSAFTINVITMCNT'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.viewType: #CONSUMPTION
@VDM.private:true
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.serviceQuality: #A
@ObjectModel.usageType.dataClass: #TRANSACTIONAL
@ClientHandling.algorithm: #SESSION_VARIABLE

// This view lists documents that have at least one line item which is not a tax line item nor customer/supplier line item.


define view P_RO_SAFTInvoiceItemCount
  with parameters
    P_AlternativeGLAccountIsUsed : saft_ro_alt_gl_account_flag

  as select from           P_RO_SAFTOplAcctgDocItmExc(P_AlternativeGLAccountIsUsed: $parameters.P_AlternativeGLAccountIsUsed) as Bseg

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

    inner join             I_TaxCode                                                                                          as taxcode            on  taxcode.TaxCalculationProcedure = TaxCountry.CostingSheetProcedure
                                                                                                                                                    and taxcode.TaxCode                 = Bseg.TaxCode

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

{
  key Bseg.CompanyCode,
  key Bseg.FiscalYear,
  key Bseg.AccountingDocument,
      Bseg.PostingDate,
      Bseg.AccountingDocumentType,
      taxcode.TaxType
}
/**
  The same WHERE condition is used in C_RO_SAFTSalesInvoiceItemC and C_RO_SAFTPurInvoiceItemC.
  If you adjust it here keep in mind to update in other places as well.
**/
where
  // exclude customer vendor lines

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

       Bseg.AccountingDocumentItemType <> 'T'
group by
  Bseg.CompanyCode,
  Bseg.FiscalYear,
  Bseg.AccountingDocument,
  Bseg.PostingDate,
  Bseg.AccountingDocumentType,
  taxcode.TaxType