P_AR_VATPrintPurchaseDetail

DDL: P_AR_VATPRINTPURCHASEDETAIL SQL: PARVATPRNTPURDET Type: view CONSUMPTION

P_AR_VATPrintPurchaseDetail is a Consumption CDS View in SAP S/4HANA. It reads from 4 data sources (P_AR_JournalEntry, I_Supplier, P_AR_SupplierPayable, P_AR_VATPrntPurTxAmtClfnAggrgd) and exposes 43 fields with key fields CompanyCode, FiscalYear, AccountingDocument, Supplier. It has 1 association to related views.

Data Sources (4)

SourceAliasJoin Type
P_AR_JournalEntry JournalEntry from
I_Supplier Supplier inner
P_AR_SupplierPayable SupplierPayable inner
P_AR_VATPrntPurTxAmtClfnAggrgd TaxItem inner

Associations (1)

CardinalityTargetAliasCondition
[1] I_AR_OfficialDocumentTypeText _AR_OffDocTypeTextImprtDsptch _AR_OffDocTypeTextImprtDsptch.Language = $session.system_language and _AR_OffDocTypeTextImprtDsptch.AR_OfficialDocumentType = '066'

Annotations (10)

NameValueLevelField
AbapCatalog.sqlViewName PARVATPRNTPURDET 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 (43)

KeyFieldSource TableSource FieldDescription
KEY CompanyCode P_AR_JournalEntry CompanyCode
KEY FiscalYear P_AR_JournalEntry FiscalYear
KEY AccountingDocument P_AR_JournalEntry AccountingDocument
KEY Supplier P_AR_SupplierPayable Supplier
CompanyCodeCountry
ExchangeRateDate P_AR_JournalEntry ExchangeRateDate
ExchangeRate P_AR_JournalEntry ExchangeRate
AccountingDocumentType P_AR_JournalEntry AccountingDocumentType
FiscalPeriod P_AR_JournalEntry FiscalPeriod
PostingDate P_AR_JournalEntry PostingDate
DocumentDate P_AR_JournalEntry DocumentDate
ReportingDate P_AR_JournalEntry ReportingDate
ReferenceDocumentType P_AR_JournalEntry ReferenceDocumentType
DocumentReferenceID P_AR_JournalEntry DocumentReferenceID
IsReversal P_AR_JournalEntry IsReversal
IsReversed P_AR_JournalEntry IsReversed
ReverseDocument P_AR_JournalEntry ReverseDocument
ReversalReferenceDocument P_AR_JournalEntry ReversalReferenceDocument
OriginalReferenceDocument P_AR_JournalEntry OriginalReferenceDocument
ClearingDate P_AR_SupplierPayable ClearingDate
ClearingAccountingDocument P_AR_SupplierPayable ClearingAccountingDocument
ImportDispatchCountry
IsOneTimeAccount I_Supplier IsOneTimeAccount
TaxNumberType80thenXendasisAduana
AR_Branch P_AR_JournalEntry AR_Branch
AR_PrintCharacter P_AR_JournalEntry AR_PrintCharacter
AR_OfficialDocumentNumber P_AR_JournalEntry AR_OfficialDocumentNumber
CompanyCodeCurrency P_AR_VATPrntPurTxAmtClfnAggrgd CompanyCodeCurrency
TransactionCurrency P_AR_VATPrntPurTxAmtClfnAggrgd TransactionCurrency
TaxBaseAmountInCoCodeCrcy P_AR_VATPrntPurTxAmtClfnAggrgd TaxBaseAmountInCoCodeCrcy
TaxAmountInCoCodeCrcy P_AR_VATPrntPurTxAmtClfnAggrgd TaxAmountInCoCodeCrcy
TaxedAmountInCoCoCrcy P_AR_VATPrntPurTxAmtClfnAggrgd TaxedAmountInCoCoCrcy
NotTaxedAmount P_AR_VATPrntPurTxAmtClfnAggrgd NotTaxedAmount
TaxExemptionAmount P_AR_VATPrntPurTxAmtClfnAggrgd TaxExemptionAmount
ImportAmountInCompanyCodeCrcy P_AR_VATPrntPurTxAmtClfnAggrgd ImportAmountInCompanyCodeCrcy
RegisteredBPTaxAmount P_AR_VATPrntPurTxAmtClfnAggrgd RegisteredBPTaxAmount
NotRegisteredBPTxAmtInCoCoCrcy P_AR_VATPrntPurTxAmtClfnAggrgd NotRegisteredBPTxAmtInCoCoCrcy
PerceptionVATAmount P_AR_VATPrntPurTxAmtClfnAggrgd PerceptionVATAmount
OtherTaxAmount P_AR_VATPrntPurTxAmtClfnAggrgd OtherTaxAmount
GrossIncomeTaxAmount P_AR_VATPrntPurTxAmtClfnAggrgd GrossIncomeTaxAmount
MunicipalTaxAmount P_AR_VATPrntPurTxAmtClfnAggrgd MunicipalTaxAmount
_AR_OffDocTypeTextImprtDsptch _AR_OffDocTypeTextImprtDsptch
_CompanyCode _CompanyCode
@AbapCatalog.sqlViewName: 'PARVATPRNTPURDET'
@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_VATPrintPurchaseDetail
  as select from P_AR_JournalEntry                                                as JournalEntry
    inner join             P_AR_VATPrntPurTxAmtClfnAggrgd as TaxItem          on  JournalEntry.CompanyCode        = TaxItem.CompanyCode
                                                                              and JournalEntry.AccountingDocument = TaxItem.AccountingDocument
                                                                              and JournalEntry.FiscalYear         = TaxItem.FiscalYear

    inner join             P_AR_SupplierPayable           as SupplierPayable  on  JournalEntry.CompanyCode        = SupplierPayable.CompanyCode
                                                                              and JournalEntry.FiscalYear         = SupplierPayable.FiscalYear
                                                                              and JournalEntry.AccountingDocument = SupplierPayable.AccountingDocument

    inner join             I_Supplier                     as Supplier         on Supplier.Supplier = SupplierPayable.Supplier
      
    left outer to one join I_OneTimeAccountBP             as OneTimeAccountBP on  JournalEntry.CompanyCode        = OneTimeAccountBP.CompanyCode
                                                                              and JournalEntry.AccountingDocument = OneTimeAccountBP.AccountingDocument
                                                                              and JournalEntry.FiscalYear         = OneTimeAccountBP.FiscalYear
      
    association [1] to I_AR_OfficialDocumentTypeText      as _AR_OffDocTypeTextImprtDsptch on  _AR_OffDocTypeTextImprtDsptch.Language                = $session.system_language
                                                                                           and _AR_OffDocTypeTextImprtDsptch.AR_OfficialDocumentType = '066'

{
  key JournalEntry.CompanyCode,
  key JournalEntry.FiscalYear,
  key JournalEntry.AccountingDocument,
  key SupplierPayable.Supplier,
      JournalEntry._CompanyCode.Country                                           as CompanyCodeCountry,
      JournalEntry.ExchangeRateDate,
      JournalEntry.ExchangeRate,
      JournalEntry.AccountingDocumentType,
      JournalEntry.FiscalPeriod,
      JournalEntry.PostingDate,
      JournalEntry.DocumentDate,
      JournalEntry.ReportingDate,
      JournalEntry.ReferenceDocumentType,
      JournalEntry.DocumentReferenceID,
      JournalEntry.IsReversal,
      JournalEntry.IsReversed,
      JournalEntry.ReverseDocument,
      JournalEntry.ReversalReferenceDocument,
      JournalEntry.OriginalReferenceDocument,
      SupplierPayable.ClearingDate,
      SupplierPayable.ClearingAccountingDocument,

      cast( substring( JournalEntry.AccountingDocumentHeaderText,1,2 ) as land1 ) as ImportDispatchCountry,

      Supplier.IsOneTimeAccount,

      cast(
        case
          when Supplier.IsOneTimeAccount = 'X'
            then OneTimeAccountBP.Country
          when Supplier.IsOneTimeAccount <> 'X'
            then Supplier.Country
        end as glo_partner_country  preserving type
      )                                                                           as BusinessPartnerCountry,

      cast(
        case
          when Supplier.IsOneTimeAccount = 'X'
            then OneTimeAccountBP.BusinessPartnerName1
          when Supplier.IsOneTimeAccount <> 'X'
            then Supplier.OrganizationBPName1
        end as businesspartnername
      )                                                                           as BusinessPartnerName,

      cast(
        case
          when Supplier.IsOneTimeAccount = 'X'
            then OneTimeAccountBP.TaxID1
          when Supplier.IsOneTimeAccount <> 'X'
            then Supplier.TaxNumber1
        end as stcd1 preserving type
      )                                                                           as TaxNumber1,

      cast(
        case
          when Supplier.IsOneTimeAccount = 'X'
            then OneTimeAccountBP.TaxNumberType
          when Supplier.IsOneTimeAccount <> 'X'
            then Supplier.TaxNumberType
        end as j_1atoid preserving type
      )                                                                           as TaxNumberType,
      
      case
        when ( Supplier.TaxNumber1 = '30546676591' or
               Supplier.TaxNumber1 = '33693450239' or
               OneTimeAccountBP.TaxID1 = '30546676591' or
               OneTimeAccountBP.TaxID1 = '33693450239' ) and
             ( Supplier.TaxNumberType = '80' or
               OneTimeAccountBP.TaxNumberType = '80' )
          then 'X'
      end                                                                         as isAduana,

      JournalEntry.AR_Branch,
      JournalEntry.AR_PrintCharacter,
      JournalEntry.AR_OfficialDocumentNumber,
      
      @Semantics.currencyCode:true
      TaxItem.CompanyCodeCurrency,

      @Semantics.currencyCode:true
      TaxItem.TransactionCurrency,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      TaxItem.TaxBaseAmountInCoCodeCrcy,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      TaxItem.TaxAmountInCoCodeCrcy,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      cast(
        abs( TaxItem.TaxBaseAmountInCoCodeCrcy + TaxItem.TaxAmountInCoCodeCrcy )
      as glo_amount_compcode_crcy )                                               as AmountInCompanyCodeCurrency,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      TaxItem.TaxedAmountInCoCoCrcy,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      TaxItem.NotTaxedAmount,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      TaxItem.TaxExemptionAmount,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      TaxItem.ImportAmountInCompanyCodeCrcy,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      TaxItem.RegisteredBPTaxAmount,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      TaxItem.NotRegisteredBPTxAmtInCoCoCrcy,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      TaxItem.PerceptionVATAmount,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      TaxItem.OtherTaxAmount,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      TaxItem.GrossIncomeTaxAmount,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      TaxItem.MunicipalTaxAmount,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      cast (
        TaxItem.TaxedAmountInCoCoCrcy + 
        TaxItem.NotTaxedAmount +
        TaxItem.RegisteredBPTaxAmount +
        TaxItem.NotRegisteredBPTxAmtInCoCoCrcy +
        TaxItem.PerceptionVATAmount +
        TaxItem.OtherTaxAmount +
        TaxItem.GrossIncomeTaxAmount +
        TaxItem.MunicipalTaxAmount +
        TaxItem.TaxExemptionAmount +
        TaxItem.ImportAmountInCompanyCodeCrcy
      as fiar_total_amount_incompcrcy )                                           as TotalAmountInCoCodeCrcy,

      _AR_OffDocTypeTextImprtDsptch,
      _CompanyCode
}
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_COMPANYCODE",
"I_ONETIMEACCOUNTBP",
"I_SUPPLIER",
"P_AR_JOURNALENTRY",
"P_AR_SUPPLIERPAYABLE",
"P_AR_VATPRNTPURTXAMTCLFNAGGRGD"
],
"ASSOCIATED":
[
"I_AR_OFFICIALDOCUMENTTYPETEXT",
"I_COMPANYCODE"
],
"BASE":
[
"P_AR_JOURNALENTRY"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/