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 3 data sources (I_OperationalAcctgDocItem, I_JournalEntryItemOneTimeData, P_RO_SAFTBSECTaxID) and exposes 11 fields with key fields CompanyCode, AccountingDocument, FiscalYear, AccountingDocumentItem.

Data Sources (3)

SourceAliasJoin Type
I_OperationalAcctgDocItem Bseg inner
I_JournalEntryItemOneTimeData Otc from
P_RO_SAFTBSECTaxID OtcStcd inner

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 (11)

KeyFieldSource TableSource FieldDescription
KEY CompanyCode I_JournalEntryItemOneTimeData CompanyCode
KEY AccountingDocument I_JournalEntryItemOneTimeData AccountingDocument
KEY FiscalYear I_JournalEntryItemOneTimeData FiscalYear
KEY AccountingDocumentItem I_JournalEntryItemOneTimeData AccountingDocumentItem
Customer I_OperationalAcctgDocItem Customer
CityName I_JournalEntryItemOneTimeData CityName
Country I_JournalEntryItemOneTimeData Country
PostalCode I_JournalEntryItemOneTimeData PostalCode
StreetName I_JournalEntryItemOneTimeData StreetAddressName
Region I_JournalEntryItemOneTimeData Region
BusinessPartnerName1 I_JournalEntryItemOneTimeData BusinessPartnerName1
@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_JournalEntryItemOneTimeData as Otc
    inner join             P_RO_SAFTBSECTaxID            as OtcStcd          on  Otc.CompanyCode            = OtcStcd.CompanyCode
                                                                             and Otc.AccountingDocument     = OtcStcd.AccountingDocument
                                                                             and Otc.FiscalYear             = OtcStcd.FiscalYear
                                                                             and Otc.AccountingDocumentItem = OtcStcd.AccountingDocumentItem
    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 Bseg.VATRegistration = '' then
             case when OtcStcd.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', OtcStcd.VATRegistration)
             end
           else '080000000000000'
           end
       when Otc.Country = 'RO' then
         case when Bseg.VATRegistration = '' then
           case when OtcStcd.VATRegistration = '' then '080000000000000'
           else concat('00', OtcStcd.VATRegistration)
           end
         else replace(Bseg.VATRegistration, 'RO', '00')
         end
       when BsegStcegCountry.IsEuropeanUnionMember = '' then
         case when Bseg.VATRegistration = '' then
           case when OtcStcd.VATRegistration = '' then concat('06', concat(Otc.Country, ltrim( Bseg.Customer, '0')))
           else case left(OtcStcd.VATRegistration, 2)
             when Otc.Country then concat('02', OtcStcd.VATRegistration)
             else concat('09', OtcStcd.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 OtcStcd.VATRegistration = ''
             then concat('05', concat(Otc.Country, ltrim( Bseg.Customer, '0')))
             else case left(OtcStcd.VATRegistration, 2)
               when Otc.Country then concat('10', concat(Otc.Country, ltrim( Bseg.Customer, '0')))
               else concat('09', OtcStcd.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

}
where
      Otc.IsOneTimeAccount      = 'X'
  and Bseg.FinancialAccountType = 'D'
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_COUNTRY",
"I_JOURNALENTRYITEMONETIMEDATA",
"I_OPERATIONALACCTGDOCITEM",
"P_RO_SAFTBSECTAXID"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/