P_LU_SAFTTaxRatioCalculation

DDL: P_LU_SAFTTAXRATIOCALCULATION SQL: PLUSAFTTAXRATCAL Type: view COMPOSITE

P_LU_SAFTTaxRatioCalculation is a Composite CDS View in SAP S/4HANA. It reads from 2 data sources (P_LU_SAFTTAXRATIODPCALC, I_LU_SAFTJournalEntry) and exposes 57 fields with key fields CompanyCode, FiscalYear, AccountingDocument, LedgerGLLineItem, Ledger.

Data Sources (2)

SourceAliasJoin Type
P_LU_SAFTTAXRATIODPCALC DP union
I_LU_SAFTJournalEntry JournalEntryItem from

Annotations (11)

NameValueLevelField
AbapCatalog.sqlViewName PLUSAFTTAXRATCAL view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
AccessControl.authorizationCheck #CHECK view
VDM.private true view
VDM.viewType #COMPOSITE view
ObjectModel.usageType.sizeCategory #XL view
ObjectModel.usageType.dataClass #MIXED view
ObjectModel.usageType.serviceQuality #P view
ClientHandling.algorithm #SESSION_VARIABLE view
AccessControl.personalData.blocking #NOT_REQUIRED view

Fields (57)

KeyFieldSource TableSource FieldDescription
KEY CompanyCode I_LU_SAFTJournalEntry CompanyCode
KEY FiscalYear I_LU_SAFTJournalEntry FiscalYear
KEY AccountingDocument I_LU_SAFTJournalEntry AccountingDocument
KEY LedgerGLLineItem I_LU_SAFTJournalEntry LedgerGLLineItem
KEY Ledger I_LU_SAFTJournalEntry Ledger
ChartOfAccounts I_LU_SAFTJournalEntry ChartOfAccounts
PostingDate I_LU_SAFTJournalEntry PostingDate
FinancialAccountType I_LU_SAFTJournalEntry FinancialAccountType
GLAccount I_LU_SAFTJournalEntry GLAccount
DocumentItemText I_LU_SAFTJournalEntry DocumentItemText
CompanyCodeCurrency I_LU_SAFTJournalEntry CompanyCodeCurrency
TransactionCurrency I_LU_SAFTJournalEntry TransactionCurrency
TaxCodeelseendasTaxCode
TaxRate1020else0endasTaxRate
fltpelse0endasTaxRatioCalculated
fltpelse0endasTaxBaseRatioCalculated
fltpelse0endasTaxBaseRatioCalculatedTC
Quantity
Customer I_LU_SAFTJournalEntry Customer
Supplier I_LU_SAFTJournalEntry Supplier
ExchangeRate I_LU_SAFTJournalEntry ExchangeRate
CAIsDownPaymentRequest
IsReversal I_LU_SAFTJournalEntry IsReversal
AccountingDocumentItemType I_LU_SAFTJournalEntry AccountingDocumentItemType
AccountingDocumentType I_LU_SAFTJournalEntry AccountingDocumentType
AlternativeGLAccount I_LU_SAFTJournalEntry AlternativeGLAccount
CompanyCode
KEY FiscalYear P_LU_SAFTTAXRATIODPCALC FiscalYear
KEY AccountingDocument P_LU_SAFTTAXRATIODPCALC AccountingDocument
KEY LedgerGLLineItem P_LU_SAFTTAXRATIODPCALC LedgerGLLineItem
KEY Ledger P_LU_SAFTTAXRATIODPCALC Ledger
ChartOfAccounts P_LU_SAFTTAXRATIODPCALC ChartOfAccounts
PostingDate P_LU_SAFTTAXRATIODPCALC PostingDate
FinancialAccountType P_LU_SAFTTAXRATIODPCALC FinancialAccountType
GLAccount P_LU_SAFTTAXRATIODPCALC GLAccount
DocumentItemText P_LU_SAFTTAXRATIODPCALC DocumentItemText
CompanyCodeCurrency P_LU_SAFTTAXRATIODPCALC CompanyCodeCurrency
TransactionCurrency P_LU_SAFTTAXRATIODPCALC TransactionCurrency
AmountInCompanyCodeCurrency P_LU_SAFTTAXRATIODPCALC AmountInCompanyCodeCurrency
AmountInTransactionCurrency P_LU_SAFTTAXRATIODPCALC AmountInTransactionCurrency
DebitCreditCode P_LU_SAFTTAXRATIODPCALC DebitCreditCode
TaxCode P_LU_SAFTTAXRATIODPCALC TaxCode
TaxRate P_LU_SAFTTAXRATIODPCALC TaxRate
TaxRatioCalculated P_LU_SAFTTAXRATIODPCALC TaxRatioCalculated
TaxRatioCalculatedTransCrcy P_LU_SAFTTAXRATIODPCALC TaxRatioCalculatedTransCrcy
TaxBaseRatioCalculated P_LU_SAFTTAXRATIODPCALC TaxBaseRatioCalculated
TaxBaseRatioCalculatedTC P_LU_SAFTTAXRATIODPCALC TaxBaseRatioCalculatedTC
Quantity P_LU_SAFTTAXRATIODPCALC Quantity
Customer P_LU_SAFTTAXRATIODPCALC Customer
Supplier P_LU_SAFTTAXRATIODPCALC Supplier
ExchangeRate P_LU_SAFTTAXRATIODPCALC ExchangeRate
CAIsDownPaymentRequest P_LU_SAFTTAXRATIODPCALC CAIsDownPaymentRequest
IsReversal
AccountingDocumentItemType
AccountingDocumentType
AlternativeGLAccount
_CompanyCodeCurrency _CompanyCodeCurrency
@AbapCatalog.sqlViewName: 'PLUSAFTTAXRATCAL'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@VDM.private: true
@VDM.viewType: #COMPOSITE
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.dataClass:  #MIXED
@ObjectModel.usageType.serviceQuality: #P
@ClientHandling.algorithm: #SESSION_VARIABLE
@AccessControl.personalData.blocking : #NOT_REQUIRED
define view P_LU_SAFTTaxRatioCalculation

  as select from           I_LU_SAFTJournalEntry      as JournalEntryItem

    left outer to one join P_LU_SAFTJournalItemTaxSum as JournalItemTaxSum on  JournalItemTaxSum.CompanyCode        = JournalEntryItem.CompanyCode
                                                                           and JournalItemTaxSum.FiscalYear         = JournalEntryItem.FiscalYear
                                                                           and JournalItemTaxSum.AccountingDocument = JournalEntryItem.AccountingDocument
                                                                           and JournalItemTaxSum.Ledger             = JournalEntryItem.Ledger
                                                                           and JournalItemTaxSum.TaxCode            = JournalEntryItem.TaxCode

    left outer to one join P_LU_SAFTTaxItemAbs        as TaxAmountSum      on  TaxAmountSum.CompanyCode        = JournalEntryItem.CompanyCode
                                                                           and TaxAmountSum.AccountingDocument = JournalEntryItem.AccountingDocument
                                                                           and TaxAmountSum.FiscalYear         = JournalEntryItem.FiscalYear
                                                                           and TaxAmountSum.TaxCode            = JournalEntryItem.TaxCode

    left outer to one join P_LU_SAFTJournalTax        as DownPayment       on  DownPayment.CompanyCode            = JournalEntryItem.CompanyCode
                                                                           and DownPayment.FiscalYear             = JournalEntryItem.FiscalYear
                                                                           and DownPayment.AccountingDocument     = JournalEntryItem.AccountingDocument
                                                                           and DownPayment.AccountingDocumentItem = JournalEntryItem.AccountingDocumentItem

{
      //      @ObjectModel.foreignKey.association: '_CompanyCode'

  key JournalEntryItem.CompanyCode                                   as CompanyCode,
      //      @ObjectModel.foreignKey.association: '_FiscalYear'

  key JournalEntryItem.FiscalYear                                    as FiscalYear,
  key JournalEntryItem.AccountingDocument                            as AccountingDocument,
  key JournalEntryItem.LedgerGLLineItem                              as LedgerGLLineItem,
      //      @ObjectModel.foreignKey.association: '_Ledger'

  key JournalEntryItem.Ledger                                        as Ledger,

      JournalEntryItem.ChartOfAccounts,
      JournalEntryItem.PostingDate,
      JournalEntryItem.FinancialAccountType,
      JournalEntryItem.GLAccount,
      JournalEntryItem.DocumentItemText,
      @Semantics.currencyCode: true
      JournalEntryItem.CompanyCodeCurrency,
      @Semantics.currencyCode: true
      JournalEntryItem.TransactionCurrency,

      @DefaultAggregation: #SUM
      @Semantics: { amount : {currencyCode: 'CompanyCodeCurrency'} }
      @EndUserText.label: 'Amount Company Code'
      case
        when JournalEntryItem.DebitCreditCode = 'H'
          then cast(abs( JournalEntryItem.AmountInCompanyCodeCurrency ) as fis_cr_hsl preserving type)
        else cast(abs ( JournalEntryItem.AmountInCompanyCodeCurrency ) as fis_cr_hsl preserving type)
      end                                                            as AmountInCompanyCodeCurrency,

      @DefaultAggregation: #SUM
      //      @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }

      @EndUserText.label: 'Amount Transaction'
      case
        when JournalEntryItem.DebitCreditCode = 'H'
          then cast(abs( JournalEntryItem.AmountInTransactionCurrency ) as fis_cr_hsl preserving type)
        else cast(abs ( JournalEntryItem.AmountInTransactionCurrency ) as fis_cr_hsl preserving type)
      end                                                            as AmountInTransactionCurrency,

      case
        when JournalEntryItem.DebitCreditCode = 'H'
          then 'C'
        else 'D'
      end                                                            as DebitCreditCode,

      case
        when JournalEntryItem.TransactionTypeDetermination = ' '
        and JournalEntryItem.FinancialAccountType = 'S'
          then JournalEntryItem.TaxCode
          else ' '
      end                                                            as TaxCode,

      case
        when JournalEntryItem.TransactionTypeDetermination = ' '
        and JournalEntryItem.FinancialAccountType = 'S'
          then coalesce(division(abs(TaxAmountSum.TaxRate),10,2) , 0)
          else 0
      end                                                            as TaxRate,

      @DefaultAggregation: #SUM
      @Semantics: { amount : {currencyCode: 'CompanyCodeCurrency'} }
      case
        when TaxAmountSum.TaxAmountInCoCodeCrcy is not initial and TaxAmountSum.TaxAmountInCoCodeCrcy is not null
        and JournalItemTaxSum.TotalGrossAmountInCoCodeCrcy is not initial and JournalItemTaxSum.TotalGrossAmountInCoCodeCrcy is not null
        and JournalEntryItem.TransactionTypeDetermination = ' '
        and JournalEntryItem.FinancialAccountType = 'S'
          then ( cast( TaxAmountSum.TaxAmountInCoCodeCrcy as abap.fltp) *
                 (cast( abs(JournalEntryItem.AmountInCompanyCodeCurrency) as abap.fltp) /
                  cast( JournalItemTaxSum.TotalGrossAmountInCoCodeCrcy as abap.fltp)))
        else 0
      end                                                            as TaxRatioCalculated,

      @DefaultAggregation: #SUM
      //      @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }

      case
        when TaxAmountSum.TaxAmount is not initial and TaxAmountSum.TaxAmount is not null
        and JournalItemTaxSum.TotalGrossAmountInTransCrcy is not initial and JournalItemTaxSum.TotalGrossAmountInTransCrcy is not null
        and JournalEntryItem.TransactionTypeDetermination = ' '
        and JournalEntryItem.FinancialAccountType = 'S'
          then ( cast( TaxAmountSum.TaxAmount as abap.fltp) *
                 (cast( abs(JournalEntryItem.AmountInTransactionCurrency) as abap.fltp) /
                  cast( JournalItemTaxSum.TotalGrossAmountInTransCrcy as abap.fltp)))
        else 0
      end                                                            as TaxRatioCalculatedTransCrcy,

      @DefaultAggregation: #SUM
      @Semantics: { amount : {currencyCode: 'CompanyCodeCurrency'} }
      case
        when TaxAmountSum.TaxBaseAmountInCoCodeCrcy is not initial and TaxAmountSum.TaxBaseAmountInCoCodeCrcy is not null
        and JournalItemTaxSum.TotalGrossAmountInCoCodeCrcy is not initial and JournalItemTaxSum.TotalGrossAmountInCoCodeCrcy is not null
        and JournalEntryItem.TransactionTypeDetermination = ' '
        and JournalEntryItem.FinancialAccountType = 'S'
          then ( cast( TaxAmountSum.TaxBaseAmountInCoCodeCrcy as abap.fltp) *
                 (cast( abs(JournalEntryItem.AmountInCompanyCodeCurrency) as abap.fltp) /
                  cast( JournalItemTaxSum.TotalGrossAmountInCoCodeCrcy as abap.fltp)))
        else 0
      end                                                            as TaxBaseRatioCalculated,

      @DefaultAggregation: #SUM
      //      @Semantics: { amount : {currencyCode: 'TransactionCurrency'} }

      case
        when TaxAmountSum.TaxBaseAmountInTransCrcy is not initial and TaxAmountSum.TaxBaseAmountInTransCrcy is not null
        and JournalItemTaxSum.TotalGrossAmountInTransCrcy is not initial and JournalItemTaxSum.TotalGrossAmountInTransCrcy is not null
        and JournalEntryItem.TransactionTypeDetermination = ' '
        and JournalEntryItem.FinancialAccountType = 'S'
          then ( cast( TaxAmountSum.TaxBaseAmountInTransCrcy as abap.fltp) *
                 (cast( abs(JournalEntryItem.AmountInTransactionCurrency) as abap.fltp) /
                  cast( JournalItemTaxSum.TotalGrossAmountInTransCrcy as abap.fltp)))
        else 0
      end                                                            as TaxBaseRatioCalculatedTC,

      cast( abs(round( JournalEntryItem.Quantity, 0)) as abap.int8 ) as Quantity,

      //     @ObjectModel.foreignKey.association: '_Customer'

      JournalEntryItem.Customer                                      as Customer,
      //      @ObjectModel.foreignKey.association: '_Supplier'

      JournalEntryItem.Supplier                                      as Supplier,
      JournalEntryItem.ExchangeRate,
      ' '                                                            as CAIsDownPaymentRequest,

      JournalEntryItem.IsReversal,
      JournalEntryItem.AccountingDocumentItemType,
      JournalEntryItem.AccountingDocumentType,
      JournalEntryItem.AlternativeGLAccount,


      //Associations

      //      JournalEntryItem._CompanyCode,

      //      JournalEntryItem._FiscalYear,

      //      JournalEntryItem._Ledger,

      //      JournalEntryItem._Supplier,

      //      JournalEntryItem._Customer,

      JournalEntryItem._CompanyCodeCurrency


}

where
  DownPayment.CAIsDownPaymentRequest = ' ' or  
  DownPayment.CAIsDownPaymentRequest is null


union select from P_LU_SAFTTAXRATIODPCALC as DP
{
  key DP.CompanyCode,
  key DP.FiscalYear,
  key DP.AccountingDocument,
  key DP.LedgerGLLineItem,
  key DP.Ledger,

      DP.ChartOfAccounts,
      DP.PostingDate,
      DP.FinancialAccountType,
      DP.GLAccount,
      DP.DocumentItemText,
      DP.CompanyCodeCurrency,
      DP.TransactionCurrency,
      DP.AmountInCompanyCodeCurrency,
      DP.AmountInTransactionCurrency,
      DP.DebitCreditCode,
      DP.TaxCode,
      DP.TaxRate,
      DP.TaxRatioCalculated,
      DP.TaxRatioCalculatedTransCrcy,
      DP.TaxBaseRatioCalculated,
      DP.TaxBaseRatioCalculatedTC,
      DP.Quantity,
      DP.Customer,
      DP.Supplier,
      DP.ExchangeRate,
      DP.CAIsDownPaymentRequest,
      '' as IsReversal,
      '' as AccountingDocumentItemType,
      '' as AccountingDocumentType,
      '' as AlternativeGLAccount,

      //    _CompanyCode,

      //    _FiscalYear,

      //     _Ledger,

      //      _Supplier,

      //     _Customer,

      _CompanyCodeCurrency

}
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_LU_SAFTJOURNALENTRY",
"P_LU_SAFTJOURNALITEMTAXSUM",
"P_LU_SAFTJOURNALTAX",
"P_LU_SAFTTAXITEMABS",
"P_LU_SAFTTAXRATIODPCALC"
],
"ASSOCIATED":
[
"I_CURRENCY"
],
"BASE":
[
"I_LU_SAFTJOURNALENTRY"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/