P_RO_SAFTCActgStdPartAddrTxNr

DDL: P_RO_SAFTCACTGSTDPARTADDRTXNR Type: view_entity CONSUMPTION Package: FKK_ID_RO_REP

Standard Partner Address and Tax Number

P_RO_SAFTCActgStdPartAddrTxNr is a Consumption CDS View that provides data about "Standard Partner Address and Tax Number" in SAP S/4HANA. It reads from 3 data sources (I_BusinessPartner, P_RO_SAFTCActgStdPartAddr, I_Country) and exposes 9 fields with key fields BusinessPartner, BPTaxTypeelseendasBPTaxType. Part of development package FKK_ID_RO_REP.

Data Sources (3)

SourceAliasJoin Type
I_BusinessPartner BP from
P_RO_SAFTCActgStdPartAddr BPAddr left_outer
I_Country Country left_outer

Annotations (7)

NameValueLevelField
AccessControl.authorizationCheck #NOT_REQUIRED view
Metadata.ignorePropagatedAnnotations true view
ObjectModel.usageType.serviceQuality #X view
ObjectModel.usageType.sizeCategory #S view
ObjectModel.usageType.dataClass #MIXED view
VDM.private true view
VDM.viewType #CONSUMPTION view

Fields (9)

KeyFieldSource TableSource FieldDescription
KEY BusinessPartner I_BusinessPartner BusinessPartner
KEY BPTaxTypeelseendasBPTaxType
hasRO9
BusinessPartnerCategory I_BusinessPartner BusinessPartnerCategory
CountryISOCode I_Country CountryISOCode
IsEuropeanUnionMember I_Country IsEuropeanUnionMember
BPTaxNumberelseendasBPTaxNumber
BPTaxLongNumber BPTaxRO9 BPTaxLongNumber
BPTaxLongNumberendasVATRegistration
@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
    serviceQuality: #X,
    sizeCategory: #S,
    dataClass: #MIXED
}
@VDM.private: true
@VDM.viewType: #CONSUMPTION
define view entity P_RO_SAFTCActgStdPartAddrTxNr as
select from I_BusinessPartner as BP
    left outer join P_RO_SAFTCActgStdPartAddr as BPAddr
        on BPAddr.BusinessPartner = BP.BusinessPartner
    left outer join I_Country as Country
        on Country.Country = BPAddr.Country
    left outer to one join I_Businesspartnertaxnumber as BPTax0
        on BPTax0.BusinessPartner = BP.BusinessPartner and
           BPTax0.BPTaxType = concat(Country.CountryISOCode,'0')
    left outer to one join I_Businesspartnertaxnumber as BPTax1
        on BPTax1.BusinessPartner = BP.BusinessPartner and
           BPTax1.BPTaxType = concat(Country.CountryISOCode,'1')
    left outer to one join I_Businesspartnertaxnumber as BPTax2
        on BPTax2.BusinessPartner = BP.BusinessPartner and
           BPTax2.BPTaxType = concat(Country.CountryISOCode,'2')
    left outer to one join I_Businesspartnertaxnumber as BPTaxRO9
        on BPTaxRO9.BusinessPartner = BP.BusinessPartner and
           BPTaxRO9.BPTaxType = 'RO9'
{
  key BP.BusinessPartner,
  key case
       when coalesce(BPTax0.BPTaxType,coalesce(BPTax1.BPTaxType,coalesce(BPTax2.BPTaxType,''))) <> '' then coalesce(BPTax0.BPTaxType,coalesce(BPTax1.BPTaxType,coalesce(BPTax2.BPTaxType,'')))
       else ''
      end as BPTaxType,
      replace(coalesce(BPTaxRO9.BPTaxType,''),'RO9','X') as hasRO9,
      BP.BusinessPartnerCategory,
      Country.CountryISOCode,
      Country.IsEuropeanUnionMember,
      case
       when coalesce(BPTax0.BPTaxNumber,coalesce(BPTax1.BPTaxNumber,coalesce(BPTax2.BPTaxNumber,''))) <> '' then coalesce(BPTax0.BPTaxNumber,coalesce(BPTax1.BPTaxNumber,coalesce(BPTax2.BPTaxNumber,'')))
       else ''
      end as BPTaxNumber,
      BPTaxRO9.BPTaxLongNumber as BPTaxLongNumber,
      case coalesce(BPTaxRO9.BPTaxLongNumber,'')
       when 'EXCLUDE' then ''
       when '0' then '080000000000000'
// RO9 not defined

       when '' then
         case BP.BusinessPartnerCategory
// Person

          when '1' then
           case
// P: Tax number defined

            when coalesce(BPTax0.BPTaxNumber,coalesce(BPTax1.BPTaxNumber,coalesce(BPTax2.BPTaxNumber,''))) <> '' then concat('03',replace(coalesce(BPTax0.BPTaxNumber,coalesce(BPTax1.BPTaxNumber,coalesce(BPTax2.BPTaxNumber,''))),Country.CountryISOCode,''))
// P: Tax number not defined

            else concat('04',ltrim( BP.BusinessPartner, '0'))
           end
// Organization

          else
           case
// O: Tax number defined

            when coalesce(BPTax0.BPTaxNumber,coalesce(BPTax1.BPTaxNumber,coalesce(BPTax2.BPTaxNumber,''))) <> '' then
             case Country.CountryISOCode
// O: country Romania

              when 'RO' then concat('00',replace(coalesce(BPTax0.BPTaxNumber,coalesce(BPTax1.BPTaxNumber,coalesce(BPTax2.BPTaxNumber,''))),'RO',''))
// O: country outside Romania

              else concat(left(concat(replace(Country.IsEuropeanUnionMember,'X','01'),'02'),2),concat(Country.CountryISOCode,replace(coalesce(BPTax0.BPTaxNumber,coalesce(BPTax1.BPTaxNumber,coalesce(BPTax2.BPTaxNumber,''))),Country.CountryISOCode,'')))
             end
// O: Tax number not defined

            else concat(left(concat(replace(Country.IsEuropeanUnionMember,'X','05'),'06'),2),concat(Country.CountryISOCode,ltrim( BP.BusinessPartner, '0')))
           end
         end
// RO9 defined - priority choice

       else BPTaxRO9.BPTaxLongNumber
      end as VATRegistration
}