I_RO_SAFTOneTimeCustomer

DDL: I_RO_SAFTONETIMECUSTOMER SQL: IROSAFTOTC Type: view COMPOSITE

RO SAFT One Time Customer

I_RO_SAFTOneTimeCustomer is a Composite CDS View that provides data about "RO SAFT One Time Customer" in SAP S/4HANA. It reads from 2 data sources (I_OperationalAcctgDocItem, I_RO_SAFTOneTmeCustVATRegn) and exposes 13 fields with key fields CompanyCode, AccountingDocument, FiscalYear, AccountingDocumentItem.

Data Sources (2)

SourceAliasJoin Type
I_OperationalAcctgDocItem Bseg inner
I_RO_SAFTOneTmeCustVATRegn Otc from

Annotations (11)

NameValueLevelField
AbapCatalog.sqlViewName IROSAFTOTC view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
VDM.viewType #COMPOSITE view
ObjectModel.usageType.serviceQuality #X view
ObjectModel.usageType.sizeCategory #M view
ObjectModel.usageType.dataClass #TRANSACTIONAL view
AccessControl.personalData.blocking #BLOCKED_DATA_INCLUDED view
AccessControl.authorizationCheck #MANDATORY view
ClientHandling.algorithm #SESSION_VARIABLE view
EndUserText.label RO SAFT One Time Customer view

Fields (13)

KeyFieldSource TableSource FieldDescription
KEY CompanyCode I_RO_SAFTOneTmeCustVATRegn CompanyCode
KEY AccountingDocument I_RO_SAFTOneTmeCustVATRegn AccountingDocument
KEY FiscalYear I_RO_SAFTOneTmeCustVATRegn FiscalYear
KEY AccountingDocumentItem I_RO_SAFTOneTmeCustVATRegn AccountingDocumentItem
Customer I_OperationalAcctgDocItem Customer
CityName I_RO_SAFTOneTmeCustVATRegn CityName
Country I_RO_SAFTOneTmeCustVATRegn Country
PostalCode I_RO_SAFTOneTmeCustVATRegn PostalCode
StreetName I_RO_SAFTOneTmeCustVATRegn StreetAddressName
Region I_RO_SAFTOneTmeCustVATRegn Region
BusinessPartnerName1 I_RO_SAFTOneTmeCustVATRegn BusinessPartnerName1
BusinessPartnerName2 I_RO_SAFTOneTmeCustVATRegn BusinessPartnerName2
CustomerName
@AbapCatalog.sqlViewName: 'IROSAFTOTC'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@VDM.viewType: #COMPOSITE
@ObjectModel.usageType.serviceQuality: #X
@ObjectModel.usageType.sizeCategory: #M
@ObjectModel.usageType.dataClass: #TRANSACTIONAL
@AccessControl.personalData.blocking: #BLOCKED_DATA_INCLUDED
@AccessControl.authorizationCheck: #MANDATORY
@ClientHandling.algorithm: #SESSION_VARIABLE
@EndUserText.label: 'RO SAFT One Time Customer'
define view I_RO_SAFTOneTimeCustomer
  as select from           I_RO_SAFTOneTmeCustVATRegn    as Otc
    inner join             I_OperationalAcctgDocItem     as Bseg             on  Bseg.AccountingDocument     = Otc.AccountingDocument
                                                                             and Bseg.CompanyCode            = Otc.CompanyCode
                                                                             and Bseg.FiscalYear             = Otc.FiscalYear
                                                                             and Bseg.AccountingDocumentItem = Otc.AccountingDocumentItem
    left outer to one join I_Country                     as BsegStcegCountry on BsegStcegCountry.Country = Otc.Country // BsegStcegCountry.CountryISOCode = left( Otc._OperationalAcctgDocItem.VATRegistration, 2 )

  //   and BsegStcegCountry.CountryISOCode <> ''

{
  key Otc.CompanyCode,
  key Otc.AccountingDocument,
  key Otc.FiscalYear,
  key Otc.AccountingDocumentItem,
    cast(case
       when Otc.IsNaturalPerson = 'X' then
         case
           when Otc.BankReference is not initial then Otc.BankReference
           when Bseg.VATRegistration = '' then
             case when Otc.VATRegistration = '' then
               case when Otc.Country = 'RO' then concat('04', ltrim( Bseg.Customer, '0'))
               else concat('11', concat(Otc.Country, ltrim( Bseg.Customer, '0')))
               end
             else concat('03', Otc.VATRegistration)
             end
           else '080000000000000'
           end
       when Otc.Country = 'RO' then
         case when Bseg.VATRegistration = '' then
           case when Otc.VATRegistration = '' then '080000000000000'
           else concat('00', Otc.VATRegistration)
           end
         else replace(Bseg.VATRegistration, 'RO', '00')
         end
       when BsegStcegCountry.IsEuropeanUnionMember = '' then
         case when Bseg.VATRegistration = '' then
           case when Otc.VATRegistration = '' then concat('06', concat(Otc.Country, ltrim( Bseg.Customer, '0')))
           else case left(Otc.VATRegistration, 2)
             when Otc.Country then concat('02', Otc.VATRegistration)
             else concat('09', Otc.VATRegistration)
             end
           end
         else case left(Bseg.VATRegistration, 2)
             when Otc.Country then concat('02', Bseg.VATRegistration)
             else concat('09', Bseg.VATRegistration)
             end
         end
       else case
         when Bseg.VATRegistration = '' then
           case when Otc.VATRegistration = ''
             then concat('05', concat(Otc.Country, ltrim( Bseg.Customer, '0')))
             else case left(Otc.VATRegistration, 2)
               when Otc.Country then concat('10', concat(Otc.Country, ltrim( Bseg.Customer, '0')))
               else concat('09', Otc.VATRegistration)
               end
             end
         else concat('01', Bseg.VATRegistration)
         end
       end as farp_stceg)   as VATRegistration,
      Bseg.Customer,
      Otc.CityName,
      Otc.Country,
      Otc.PostalCode,
      Otc.StreetAddressName as StreetName,
      Otc.Region,
      Otc.BusinessPartnerName1,
      Otc.BusinessPartnerName2,
      concat_with_space(Otc.BusinessPartnerName1, Otc.BusinessPartnerName2, 1) as CustomerName

}
where
      Otc.IsOneTimeAccount      = 'X'
  and Bseg.FinancialAccountType = 'D'