P_SupplierInvoiceTaxMerge

DDL: P_SUPPLIERINVOICETAXMERGE SQL: PSUPINVTAXMERGE Type: view BASIC

P_SupplierInvoiceTaxMerge is a Basic CDS View in SAP S/4HANA. It reads from 2 data sources (I_SupplierInvoice, rbkp) and exposes 13 fields with key fields SupplierInvoice, FiscalYear, mwskz1endasTaxCode. It has 4 associations to related views.

Data Sources (2)

SourceAliasJoin Type
I_SupplierInvoice I_SupplierInvoice from
rbkp rbkp inner

Associations (4)

CardinalityTargetAliasCondition
[1..1] I_SupplierInvoice _SupplierInvoice $projection.SupplierInvoice = _SupplierInvoice.SupplierInvoice and $projection.FiscalYear = _SupplierInvoice.FiscalYear
[1..1] I_TaxCode _TaxCode $projection.TaxCalculationProcedure = _TaxCode.TaxCalculationProcedure and $projection.TaxCode = _TaxCode.TaxCode
[0..*] I_TaxCodeText _TaxCodeText $projection.TaxCalculationProcedure = _TaxCodeText.TaxCalculationProcedure and $projection.TaxCode = _TaxCodeText.TaxCode
[0..1] I_Currency _Currency $projection.DocumentCurrency = _Currency.Currency

Annotations (9)

NameValueLevelField
AbapCatalog.sqlViewName PSUPINVTAXMERGE view
AbapCatalog.compiler.compareFilter true view
AccessControl.authorizationCheck #PRIVILEGED_ONLY view
AccessControl.personalData.blocking #REQUIRED view
ClientHandling.algorithm #SESSION_VARIABLE view
VDM.viewType #BASIC view
VDM.private true view
VDM.lifecycle.contract.type #NONE view
AbapCatalog.preserveKey true view

Fields (13)

KeyFieldSource TableSource FieldDescription
KEY SupplierInvoice I_SupplierInvoice SupplierInvoice
KEY FiscalYear I_SupplierInvoice FiscalYear
KEY mwskz1endasTaxCode
DocumentCurrency _SupplierInvoice DocumentCurrency
CompanyCodeCurrency
wmwst1endasTaxAmount
tax_countryendasTaxCountry
TaxCalculationProcedure
TaxDeterminationDate rbtx txdat
TaxRateValidityStartDate rbtx txdat_from
_TaxCode _TaxCode
_TaxCodeText _TaxCodeText
_Currency _Currency
@AbapCatalog.sqlViewName: 'PSUPINVTAXMERGE'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck:#PRIVILEGED_ONLY
@AccessControl.personalData.blocking: #REQUIRED
@ClientHandling.algorithm: #SESSION_VARIABLE
@VDM.viewType: #BASIC
@VDM.private: true
@VDM.lifecycle.contract.type: #NONE
@AbapCatalog.preserveKey:true

define view P_SupplierInvoiceTaxMerge
  as select from    I_SupplierInvoice
    inner join      rbkp on  I_SupplierInvoice.SupplierInvoice = rbkp.belnr
                         and I_SupplierInvoice.FiscalYear      = rbkp.gjahr
    left outer to many join rbtx on  I_SupplierInvoice.SupplierInvoice = rbtx.belnr
                                and I_SupplierInvoice.FiscalYear      = rbtx.gjahr
  association [1..1] to I_SupplierInvoice as _SupplierInvoice on  $projection.SupplierInvoice = _SupplierInvoice.SupplierInvoice
                                                              and $projection.FiscalYear      = _SupplierInvoice.FiscalYear
  association [1..1] to I_TaxCode         as _TaxCode         on  $projection.TaxCalculationProcedure = _TaxCode.TaxCalculationProcedure
                                                              and $projection.TaxCode                 = _TaxCode.TaxCode

  association [0..*] to I_TaxCodeText     as _TaxCodeText     on  $projection.TaxCalculationProcedure = _TaxCodeText.TaxCalculationProcedure
                                                              and $projection.TaxCode                 = _TaxCodeText.TaxCode

  association [0..1] to I_Currency        as _Currency        on  $projection.DocumentCurrency = _Currency.Currency
{
  key I_SupplierInvoice.SupplierInvoice         as SupplierInvoice,
  key I_SupplierInvoice.FiscalYear              as FiscalYear,
  key case
    when rbtx.mwskz <> '' then rbtx.mwskz
    else rbkp.mwskz1
  end                                           as TaxCode,
  key case
    when rbtx.mwskz <> '' then rbtx.buzei
    else cast('000001' as rblgp  preserving type)
  end                                           as SupplierInvoiceTaxCounter,

      @Semantics.currencyCode: true
      _SupplierInvoice.DocumentCurrency         as DocumentCurrency,

      _SupplierInvoice._CompanyCode.Currency    as CompanyCodeCurrency,

      @Semantics.amount.currencyCode: 'DocumentCurrency'
      @DefaultAggregation:#NONE
      case
        when rbtx.mwskz <> '' then rbtx.wmwst
        else rbkp.wmwst1
      end                                       as TaxAmount,      
      
      case
        when rbtx.mwskz <> '' then rbtx.tax_country
        else rbkp.tax_country
      end                                       as TaxCountry,            
      
      cast('      ' as kalsm_d preserving type) as TaxCalculationProcedure,

      @Semantics.amount.currencyCode: 'DocumentCurrency'
      @DefaultAggregation:#NONE
      case
        when rbtx.mwskz <> '' then rbtx.fwbas
        else cast('0' as fwbas_bses_cs)
      end                                       as TaxBaseAmountInTransCrcy,
      case
        when rbtx.mwskz <> '' then rbtx.txjcd
        else cast('               ' as txjcd preserving type)
      end                                       as TaxJurisdiction,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      @DefaultAggregation:#NONE
      case
        when rbtx.mwskz <> '' then rbtx.hwste
        else cast('0' as hwste_cs)
      end                                       as TaxAmountInCoCodeCrcy,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      @DefaultAggregation:#NONE
      case
        when rbtx.mwskz <> '' then rbtx.hwbas
        else cast('0' as hwbas_bses_cs)
      end                                       as TaxBaseAmountInCoCodeCrcy,
      
      rbtx.txdat                                as TaxDeterminationDate,
      rbtx.txdat_from                           as TaxRateValidityStartDate,

      /* Associations */
      _TaxCode,
      _TaxCodeText,
      _Currency
}
where
     rbkp.mwskz1 <> ''
  or rbtx.mwskz  <> '';
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_COMPANYCODE",
"I_SUPPLIERINVOICE",
"RBKP",
"RBTX"
],
"ASSOCIATED":
[
"I_CURRENCY",
"I_SUPPLIERINVOICE",
"I_TAXCODE",
"I_TAXCODETEXT"
],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/