P_AR_PurchaseVATRateDetail

DDL: P_AR_PURCHASEVATRATEDETAIL SQL: PARPURCVATRD Type: view CONSUMPTION

P_AR_PurchaseVATRateDetail is a Consumption CDS View in SAP S/4HANA. It reads from 2 data sources (P_AR_JrnlEntryWthOfclDocType, P_AR_PurVATRateAggregatedAmt2) and exposes 27 fields with key fields CompanyCode, FiscalYear, AccountingDocument, StatryRptCategory, StatryRptgEntity.

Data Sources (2)

SourceAliasJoin Type
P_AR_JrnlEntryWthOfclDocType P_AR_JrnlEntryWthOfclDocType inner
P_AR_PurVATRateAggregatedAmt2 PurVATRateAggregatedAmt from

Parameters (1)

NameTypeDefault
P_RptgAmountIsInTransCrcy fiar_use_transaction_currency

Annotations (10)

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

Fields (27)

KeyFieldSource TableSource FieldDescription
KEY CompanyCode JournalEntry CompanyCode
KEY FiscalYear JournalEntry FiscalYear
KEY AccountingDocument JournalEntry AccountingDocument
KEY StatryRptCategory P_AR_PurVATRateAggregatedAmt2 StatryRptCategory
KEY StatryRptgEntity P_AR_PurVATRateAggregatedAmt2 StatryRptgEntity
KEY StatryRptRunID P_AR_PurVATRateAggregatedAmt2 StatryRptRunID
KEY TaxRate P_AR_PurVATRateAggregatedAmt2 TaxRate
PostingDate JournalEntry PostingDate
DocumentDate JournalEntry DocumentDate
ReportingDate JournalEntry ReportingDate
TaxReportingDate JournalEntry TaxReportingDate
AccountingDocumentType JournalEntry AccountingDocumentType
DocumentReferenceID JournalEntry DocumentReferenceID
AR_PrintCharacter JournalEntry AR_PrintCharacter
AR_Branch JournalEntry AR_Branch
AR_OfficialDocumentNumber JournalEntry AR_OfficialDocumentNumber
AR_OfficialDocumentType JournalEntry AR_OfficialDocumentType
AR_OfficialDocumentClass JournalEntry AR_OfficialDocumentClass
CompanyCodeCountry P_AR_PurVATRateAggregatedAmt2 CompanyCodeCountry
CompanyCodeCurrency JournalEntry CompanyCodeCurrency
TaxAmountInCoCodeCrcy P_AR_PurVATRateAggregatedAmt2 TaxAmountInCoCodeCrcy
TaxBaseAmountInCoCodeCrcy P_AR_PurVATRateAggregatedAmt2 TaxBaseAmountInCoCodeCrcy
TransactionCurrency JournalEntry TransactionCurrency
TaxAmountInTransCrcy P_AR_PurVATRateAggregatedAmt2 TaxAmountInTransCrcy
TaxBaseAmountInTransCrcy P_AR_PurVATRateAggregatedAmt2 TaxBaseAmountInTransCrcy
NmbrOfVATRates NumberOfVATRates NmbrOfVATRates
_OneTimeAccountBP JournalEntry _OneTimeAccountBP
@AbapCatalog.sqlViewName: 'PARPURCVATRD'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.dataClass: #MIXED
@VDM.viewType: #CONSUMPTION
@VDM.private: true
@ClientHandling.algorithm: #SESSION_VARIABLE
define view P_AR_PurchaseVATRateDetail
  with parameters
    P_RptgAmountIsInTransCrcy : fiar_use_transaction_currency

  as select from           P_AR_PurVATRateAggregatedAmt2                                         as PurVATRateAggregatedAmt

    inner join             P_AR_JrnlEntryWthOfclDocType( P_AR_Report : 'RPFIGLAR_TAXREPORTING' ) as JournalEntry     on  JournalEntry.CompanyCode        = PurVATRateAggregatedAmt.CompanyCode
                                                                                                                     and JournalEntry.FiscalYear         = PurVATRateAggregatedAmt.FiscalYear
                                                                                                                     and JournalEntry.AccountingDocument = PurVATRateAggregatedAmt.AccountingDocument


    left outer to one join P_AR_NumberOfVATRates                                                 as NumberOfVATRates on  NumberOfVATRates.CompanyCode        = PurVATRateAggregatedAmt.CompanyCode
                                                                                                                     and NumberOfVATRates.FiscalYear         = PurVATRateAggregatedAmt.FiscalYear
                                                                                                                     and NumberOfVATRates.AccountingDocument = PurVATRateAggregatedAmt.AccountingDocument
                                                                                                                     and NumberOfVATRates.TaxType            = 'V'

{
  key JournalEntry.CompanyCode,
  key JournalEntry.FiscalYear,
  key JournalEntry.AccountingDocument,
  key PurVATRateAggregatedAmt.StatryRptCategory,
  key PurVATRateAggregatedAmt.StatryRptgEntity,
  key PurVATRateAggregatedAmt.StatryRptRunID,
  key PurVATRateAggregatedAmt.TaxRate as TaxRate,
      JournalEntry.PostingDate,
      JournalEntry.DocumentDate,
      JournalEntry.ReportingDate,
      JournalEntry.TaxReportingDate,
      JournalEntry.AccountingDocumentType,
      JournalEntry.DocumentReferenceID,
      JournalEntry.AR_PrintCharacter,
      JournalEntry.AR_Branch,
      JournalEntry.AR_OfficialDocumentNumber,
      JournalEntry.AR_OfficialDocumentType,
      JournalEntry.AR_OfficialDocumentClass,
      PurVATRateAggregatedAmt.CompanyCodeCountry,

      @Semantics.currencyCode:true
      JournalEntry.CompanyCodeCurrency,
      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      PurVATRateAggregatedAmt.TaxAmountInCoCodeCrcy,
      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      PurVATRateAggregatedAmt.TaxBaseAmountInCoCodeCrcy,

      @Semantics.currencyCode:true
      JournalEntry.TransactionCurrency,
      @Semantics.amount.currencyCode: 'TransactionCurrency'
      PurVATRateAggregatedAmt.TaxAmountInTransCrcy,
      @Semantics.amount.currencyCode: 'TransactionCurrency'
      PurVATRateAggregatedAmt.TaxBaseAmountInTransCrcy,

      @Semantics.currencyCode:true
      cast(
        case $parameters.P_RptgAmountIsInTransCrcy
          when 'X'
            then JournalEntry.TransactionCurrency
          else JournalEntry.CompanyCodeCurrency
        end as glo_reporting_currency preserving type
      )                               as ReportingCurrency,

      @Semantics.amount.currencyCode: 'ReportingCurrency'
      cast(
        case $parameters.P_RptgAmountIsInTransCrcy
          when 'X'
            then PurVATRateAggregatedAmt.TaxAmountInTransCrcy
          else PurVATRateAggregatedAmt.TaxAmountInCoCodeCrcy
        end as glo_tax_amount_rptg_crcy preserving type
      )                               as TaxAmountInRptgCrcy,

      @Semantics.amount.currencyCode: 'ReportingCurrency'
      cast(
        case $parameters.P_RptgAmountIsInTransCrcy
          when 'X'
            then PurVATRateAggregatedAmt.TaxBaseAmountInTransCrcy
          else PurVATRateAggregatedAmt.TaxBaseAmountInCoCodeCrcy
        end as glo_taxbase_amount_rptg_crcy preserving type
      )                               as TaxBaseAmountInRptgCrcy,

      NumberOfVATRates.NmbrOfVATRates,
      JournalEntry._OneTimeAccountBP
}
// considers the lines with taxes or lines with zero vat but without additional tax lines (<>zero)


where
       ( PurVATRateAggregatedAmt.TaxRate <> '0.00'
    or     ( PurVATRateAggregatedAmt.TaxRate = '0.00'
       and ( NumberOfVATRates.NmbrOfVATRates = 0 or NumberOfVATRates.NmbrOfVATRates is null ) ) )
  and
      ( ( JournalEntry.AR_PrintCharacter <> 'B' and JournalEntry.AR_PrintCharacter <> 'C' )
    or
       JournalEntry.AR_OfficialDocumentType = '033' )