P_PL_SAFTTaxItemBasic

DDL: P_PL_SAFTTAXITEMBASIC SQL: PPLSAFTTAXITMBSC Type: view COMPOSITE

P_PL_SAFTTaxItemBasic is a Composite CDS View in SAP S/4HANA. It reads from 1 data source (P_PL_SAFTTaxItemAgg) and exposes 31 fields with key fields TaxType, CompanyCode, AccountingDocument, FiscalYear. It has 3 associations to related views.

Data Sources (1)

SourceAliasJoin Type
P_PL_SAFTTaxItemAgg TaxItemAgg from

Associations (3)

CardinalityTargetAliasCondition
[0..1] P_PL_SAFTDocItemVat _DocItemVat TaxItemAgg.TaxType = _DocItemVat.TaxType and TaxItemAgg.CompanyCode = _DocItemVat.CompanyCode and TaxItemAgg.AccountingDocument = _DocItemVat.AccountingDocument and TaxItemAgg.FiscalYear = _DocItemVat.FiscalYear
[0..1] P_PL_SAFTBPTaxNumber _SAFTBPTaxNumber TaxItemAgg.TaxType = _SAFTBPTaxNumber.TaxType and TaxItemAgg.CompanyCode = _SAFTBPTaxNumber.CompanyCode and TaxItemAgg.AccountingDocument = _SAFTBPTaxNumber.AccountingDocument and TaxItemAgg.FiscalYear = _SAFTBPTaxNumber.FiscalYear
[0..1] P_PL_SAFTCountryVAT _VATCountry $projection.TaxType = _VATCountry.TaxType and $projection.CompanyCode = _VATCountry.CompanyCode and $projection.AccountingDocument = _VATCountry.AccountingDocument and $projection.FiscalYear = _VATCountry.FiscalYear

Annotations (10)

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

Fields (31)

KeyFieldSource TableSource FieldDescription
KEY TaxType P_PL_SAFTTaxItemAgg TaxType
KEY CompanyCode P_PL_SAFTTaxItemAgg CompanyCode
KEY AccountingDocument P_PL_SAFTTaxItemAgg AccountingDocument
KEY FiscalYear P_PL_SAFTTaxItemAgg FiscalYear
PL_SAFTTaxAmountBox P_PL_SAFTTaxItemAgg PL_SAFTTaxAmountBox
PL_SAFTBaseAmountBoxMultiple P_PL_SAFTTaxItemAgg PL_SAFTBaseAmountBoxMultiple
PL_SAFTDocumentType P_PL_SAFTTaxItemAgg PL_SAFTDocumentType
PL_SAFTTaxItemHasMarginAmount P_PL_SAFTTaxItemAgg PL_SAFTTaxItemHasMarginAmount
PL_SAFTAddlClassification P_PL_SAFTTaxItemAgg PL_SAFTAddlClassification
PL_SAFTInvcExclRsnFromTotals P_PL_SAFTTaxItemAgg PL_SAFTInvcExclRsnFromTotals
TaxReportingDate P_PL_SAFTTaxItemAgg TaxReportingDate
TaxReturnCountry P_PL_SAFTTaxItemAgg TaxReturnCountry
TaxCalculationProcedure P_PL_SAFTTaxItemAgg TaxCalculationProcedure
Customer P_PL_SAFTTaxItemAgg Customer
Supplier P_PL_SAFTTaxItemAgg Supplier
ReferenceDocumentType P_PL_SAFTTaxItemAgg ReferenceDocumentType
OriginalReferenceDocument P_PL_SAFTTaxItemAgg OriginalReferenceDocument
DocumentItemText P_PL_SAFTTaxItemAgg DocumentItemText
CountryendendasBusinessPartnerCountry
BPTaxNumberendendendendasVATRegistration
BusinessPartnerName P_PL_SAFTTaxItemAgg BusinessPartnerName
CustomerSupplierAddress P_PL_SAFTTaxItemAgg CustomerSupplierAddress
DocumentReferenceID P_PL_SAFTTaxItemAgg DocumentReferenceID
DocumentDate P_PL_SAFTTaxItemAgg DocumentDate
CompanyCodeCurrency P_PL_SAFTTaxItemAgg CompanyCodeCurrency
TaxAmountInCoCodeCrcy P_PL_SAFTTaxItemAgg TaxAmountInCoCodeCrcy
TaxBaseAmountInCoCodeCrcy P_PL_SAFTTaxItemAgg TaxBaseAmountInCoCodeCrcy
DocumentCurrency P_PL_SAFTTaxItemAgg DocumentCurrency
TaxBaseAmountInCountryCrcy P_PL_SAFTTaxItemAgg TaxBaseAmountInCountryCrcy
TaxAmountInCountryCrcy P_PL_SAFTTaxItemAgg TaxAmountInCountryCrcy
_AccountingDocument _AccountingDocument
@AbapCatalog.sqlViewName: 'PPLSAFTTAXITMBSC'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.viewType: #COMPOSITE
@VDM.private: true
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.dataClass:  #MIXED
@ObjectModel.usageType.serviceQuality: #X
@ClientHandling.algorithm: #SESSION_VARIABLE
define view P_PL_SAFTTaxItemBasic
  as select from P_PL_SAFTTaxItemAgg as TaxItemAgg

  association [0..1] to P_PL_SAFTDocItemVat  as _DocItemVat      on  TaxItemAgg.TaxType            = _DocItemVat.TaxType
                                                                 and TaxItemAgg.CompanyCode        = _DocItemVat.CompanyCode
                                                                 and TaxItemAgg.AccountingDocument = _DocItemVat.AccountingDocument
                                                                 and TaxItemAgg.FiscalYear         = _DocItemVat.FiscalYear

  association [0..1] to P_PL_SAFTBPTaxNumber as _SAFTBPTaxNumber on  TaxItemAgg.TaxType            = _SAFTBPTaxNumber.TaxType
                                                                 and TaxItemAgg.CompanyCode        = _SAFTBPTaxNumber.CompanyCode
                                                                 and TaxItemAgg.AccountingDocument = _SAFTBPTaxNumber.AccountingDocument
                                                                 and TaxItemAgg.FiscalYear         = _SAFTBPTaxNumber.FiscalYear

  association [0..1] to P_PL_SAFTCountryVAT  as _VATCountry      on  $projection.TaxType            = _VATCountry.TaxType
                                                                 and $projection.CompanyCode        = _VATCountry.CompanyCode
                                                                 and $projection.AccountingDocument = _VATCountry.AccountingDocument
                                                                 and $projection.FiscalYear         = _VATCountry.FiscalYear
{
  key TaxItemAgg.TaxType,
  key TaxItemAgg.CompanyCode,
  key TaxItemAgg.AccountingDocument,
  key TaxItemAgg.FiscalYear,

      TaxItemAgg.PL_SAFTTaxAmountBox,
      TaxItemAgg.PL_SAFTBaseAmountBoxMultiple,

      TaxItemAgg.PL_SAFTDocumentType,
      TaxItemAgg.PL_SAFTTaxItemHasMarginAmount,
      TaxItemAgg.PL_SAFTAddlClassification,
      TaxItemAgg.PL_SAFTInvcExclRsnFromTotals,

      case when TaxItemAgg.PL_SAFTTaxAmountBox like 'P%' or TaxItemAgg.PL_SAFTBaseAmountBoxMultiple like 'P%'
        then ' '
        else 'X'
      end as TaxItemIsIncluded,

      TaxItemAgg.TaxReportingDate,

      TaxItemAgg.TaxReturnCountry,

      TaxItemAgg.TaxCalculationProcedure,

      TaxItemAgg.Customer,
      TaxItemAgg.Supplier,
      TaxItemAgg.ReferenceDocumentType,
      TaxItemAgg.OriginalReferenceDocument,
      TaxItemAgg.DocumentItemText,

      case substring(_DocItemVat.VATRegistration,1,1)
        when '1' then _DocItemVat.SupplyingCountry
        when '2' then _DocItemVat.SupplyingCountry
        when '3' then _DocItemVat.SupplyingCountry
        when '4' then _DocItemVat.SupplyingCountry
        when '5' then _DocItemVat.SupplyingCountry
        when '6' then _DocItemVat.SupplyingCountry
        when '7' then _DocItemVat.SupplyingCountry
        when '8' then _DocItemVat.SupplyingCountry
        when '9' then _DocItemVat.SupplyingCountry
        when '0' then _DocItemVat.SupplyingCountry
      //when ''  then _DOCITEMVAT.SupplyingCountry

        else

         case
            when _DocItemVat.VATRegistration <> '' and _DocItemVat.VatCountry <> 'UN'
                then substring(_DocItemVat.VATRegistration,1,2)
            when TaxItemAgg.BusinessPartnerCountry = 'GR'
                then 'EL'
            when _DocItemVat.VatCountry = 'UN'
                then 'BY'
            when TaxItemAgg.VATRegistration <> ''
                then TaxItemAgg.BusinessPartnerCountry
            else _SAFTBPTaxNumber.Country
         end
      end as BusinessPartnerCountry,

      case substring(_DocItemVat.VATRegistration,1,1)
        when '1' then _DocItemVat.VATRegistration
        when '2' then _DocItemVat.VATRegistration
        when '3' then _DocItemVat.VATRegistration
        when '4' then _DocItemVat.VATRegistration
        when '5' then _DocItemVat.VATRegistration
        when '6' then _DocItemVat.VATRegistration
        when '7' then _DocItemVat.VATRegistration
        when '8' then _DocItemVat.VATRegistration
        when '9' then _DocItemVat.VATRegistration
        when '0' then _DocItemVat.VATRegistration
      //when ''  then _DOCITEMVAT.VATRegistration

        else

          case
              when _DocItemVat.VatCountry = 'EL'
                  then substring(_DocItemVat.VATRegistration,3,18)
              when _DocItemVat.VATRegistration <> '' and _VATCountry.VATCountry <> 'UN'
                  then substring(_DocItemVat.VATRegistration,3,18)
              when _DocItemVat.VATRegistration <> ''
                  then _DocItemVat.VATRegistration
              else

                case substring(TaxItemAgg.VATRegistration,1,1)
                    when '1' then TaxItemAgg.VATRegistration
                    when '2' then TaxItemAgg.VATRegistration
                    when '3' then TaxItemAgg.VATRegistration
                    when '4' then TaxItemAgg.VATRegistration
                    when '5' then TaxItemAgg.VATRegistration
                    when '6' then TaxItemAgg.VATRegistration
                    when '7' then TaxItemAgg.VATRegistration
                    when '8' then TaxItemAgg.VATRegistration
                    when '9' then TaxItemAgg.VATRegistration
                    when '0' then TaxItemAgg.VATRegistration
      //when ''  then TaxItemAgg.VATRegistration

              else

                    case
                        when _VATCountry.VATCountry = 'EL'
                            then substring(TaxItemAgg.VATRegistration,3,18)
                        when TaxItemAgg.VATRegistration <> '' and _VATCountry.VATCountry = _Country.Country
                            then substring(TaxItemAgg.VATRegistration,3,18)
                        else _SAFTBPTaxNumber.BPTaxNumber
                    end
                end
           end
      end as VATRegistration,

      TaxItemAgg.BusinessPartnerName,

      TaxItemAgg.CustomerSupplierAddress,

      TaxItemAgg.DocumentReferenceID,
      TaxItemAgg.DocumentDate,

      @Semantics.currencyCode: true
      TaxItemAgg.CompanyCodeCurrency,
      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      TaxItemAgg.TaxAmountInCoCodeCrcy,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      TaxItemAgg.TaxBaseAmountInCoCodeCrcy,
      
      @Semantics.currencyCode:true
      TaxItemAgg.DocumentCurrency,
      @Semantics.amount.currencyCode: 'DocumentCurrency'
       TaxItemAgg.TaxBaseAmountInCountryCrcy,
      @Semantics.amount.currencyCode: 'DocumentCurrency'
       TaxItemAgg.TaxAmountInCountryCrcy,

      case when ( TaxItemAgg.PL_SAFTDocumentType is not null or TaxItemAgg.PL_SAFTTaxItemHasMarginAmount is not null or TaxItemAgg.PL_SAFTAddlClassification is not null ) and TaxItemAgg.PL_SAFTInvcExclRsnFromTotals = '1'
        then 'X'
        else ''
      end as IndicatorValue,

      _AccountingDocument

}
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_COUNTRY",
"P_PL_SAFTBPTAXNUMBER",
"P_PL_SAFTCOUNTRYVAT",
"P_PL_SAFTDOCITEMVAT",
"P_PL_SAFTTAXITEMAGG"
],
"ASSOCIATED":
[
"I_ACCOUNTINGDOCUMENT",
"P_PL_SAFTBPTAXNUMBER",
"P_PL_SAFTCOUNTRYVAT",
"P_PL_SAFTDOCITEMVAT"
],
"BASE":
[
"P_PL_SAFTTAXITEMAGG"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/