P_ARCustomerUnion

DDL: P_ARCUSTOMERUNION SQL: PARCUSTOMERUN Type: view CONSUMPTION Package: ODATA_CUSTOMER_LIST

AR Customer Union

P_ARCustomerUnion is a Consumption CDS View that provides data about "AR Customer Union" in SAP S/4HANA. It reads from 5 data sources (I_Customer, I_Customer, I_CustomerCompany, P_ARCustomerSalesArea, P_ARCustomerSalesArea) and exposes 65 fields with key fields Customer, CompanyCode, SalesOrganization, DistributionChannel, Division. Part of development package ODATA_CUSTOMER_LIST.

Data Sources (5)

SourceAliasJoin Type
I_Customer _C from
I_Customer _C union_all
I_CustomerCompany _CC left_outer
P_ARCustomerSalesArea _CSA left_outer
P_ARCustomerSalesArea _CSA left_outer

Annotations (7)

NameValueLevelField
AbapCatalog.sqlViewName PARCUSTOMERUN view
AbapCatalog.compiler.compareFilter true view
AccessControl.authorizationCheck #NOT_REQUIRED view
EndUserText.label AR Customer Union view
ClientHandling.algorithm #SESSION_VARIABLE view
VDM.viewType #CONSUMPTION view
VDM.private true view

Fields (65)

KeyFieldSource TableSource FieldDescription
KEY Customer I_Customer Customer
KEY CompanyCode I_CustomerCompany CompanyCode
KEY SalesOrganization P_ARCustomerSalesArea SalesOrganization
KEY DistributionChannel P_ARCustomerSalesArea DistributionChannel
KEY Division P_ARCustomerSalesArea Division
KEY CustomerIsWithCompanyCode
CustomerAccountGroup I_Customer CustomerAccountGroup
_CustomerAccountGroupText I_Customer _CustomerAccountGroupText
Supplier I_Customer Supplier
PostingIsBlocked I_Customer PostingIsBlocked
AuthorizationGroup I_Customer AuthorizationGroup
CreatedByUser I_Customer CreatedByUser
VATRegistration I_Customer VATRegistration
TaxNumber1 I_Customer TaxNumber1
TaxNumber2 I_Customer TaxNumber2
TaxNumber3 I_Customer TaxNumber3
TaxNumber4 I_Customer TaxNumber4
TaxNumber5 I_Customer TaxNumber5
VATLiability I_Customer VATLiability
ResponsibleType I_Customer ResponsibleType
TaxNumberType I_Customer TaxNumberType
AddressID I_Customer AddressID
DataControllerSet I_Customer DataControllerSet
DataController1 I_Customer DataController1
DataController2 I_Customer DataController2
DataController3 I_Customer DataController3
DataController4 I_Customer DataController4
DataController5 I_Customer DataController5
DataController6 I_Customer DataController6
DataController7 I_Customer DataController7
DataController8 I_Customer DataController8
DataController9 I_Customer DataController9
Customer
KEY CompanyCode I_CustomerCompany CompanyCode
KEY SalesOrganization P_ARCustomerSalesArea SalesOrganization
KEY DistributionChannel P_ARCustomerSalesArea DistributionChannel
KEY Division P_ARCustomerSalesArea Division
KEY CustomerIsWithCompanyCode
CustomerAccountGroup I_Customer CustomerAccountGroup
_CustomerAccountGroupText I_Customer _CustomerAccountGroupText
Supplier I_Customer Supplier
PostingIsBlocked I_Customer PostingIsBlocked
AuthorizationGroup I_Customer AuthorizationGroup
CreatedByUser I_Customer CreatedByUser
VATRegistration I_Customer VATRegistration
TaxNumber1 I_Customer TaxNumber1
TaxNumber2 I_Customer TaxNumber2
TaxNumber3 I_Customer TaxNumber3
TaxNumber4 I_Customer TaxNumber4
TaxNumber5 I_Customer TaxNumber5
VATLiability I_Customer VATLiability
ResponsibleType I_Customer ResponsibleType
TaxNumberType I_Customer TaxNumberType
AddressID I_Customer AddressID
DataControllerSet I_Customer DataControllerSet
DataController1 I_Customer DataController1
DataController2 I_Customer DataController2
DataController3 I_Customer DataController3
DataController4 I_Customer DataController4
DataController5 I_Customer DataController5
DataController6 I_Customer DataController6
DataController7 I_Customer DataController7
DataController8 I_Customer DataController8
DataController9 I_Customer DataController9
DataController10 I_Customer DataController10
@AbapCatalog.sqlViewName: 'PARCUSTOMERUN'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'AR Customer Union'
@ClientHandling.algorithm: #SESSION_VARIABLE

@VDM.viewType: #CONSUMPTION
@VDM.private: true

define view P_ARCustomerUnion as 

select from I_Customer as _C
  
   left outer join I_CustomerCompany as _CC
    on _C.Customer = _CC.Customer

   left outer join P_ARCustomerSalesArea as _CSA
    on _C.Customer = _CSA.Customer
    and _CC.CompanyCode = _CSA.CompanyCode

//select from I_CustomerCompany as _CC

//

//  left outer to one join I_Customer as _C

//    on _C.Customer = _CC.Customer

//    

//  // One CC can be assigned to more CSA, solved in second branch of union

//  left outer to one join P_ARCustomerSalesArea as _CSA

//    on _CC.Customer = _CSA.Customer

//    and _CC.CompanyCode = _CSA.CompanyCode

  
//  association [0..1] to I_CustomerCompany as _CustomerCompany

//    on $projection.Customer = _CustomerCompany.Customer

//    and $projection.CompanyCode = _CustomerCompany.CompanyCode

//    

//  association [0..1] to I_CustomerSalesArea as _CustomerSalesArea

//    on $projection.Customer = _CustomerSalesArea.Customer

//    and $projection.SalesOrganization = _CustomerSalesArea.SalesOrganization

//    and $projection.DistributionChannel = _CustomerSalesArea.DistributionChannel

//    and $projection.Division = _CustomerSalesArea.Division


{
  key _C.Customer,
  key _CC.CompanyCode as CompanyCode,
  key _CSA.SalesOrganization as SalesOrganization,
  key _CSA.DistributionChannel as DistributionChannel,
  key _CSA.Division as Division,
  key 'X' as CustomerIsWithCompanyCode,
  
      _C.CustomerAccountGroup,
      _C._CustomerAccountGroupText,
      _C.Supplier,
      _C.PostingIsBlocked,
      _C.AuthorizationGroup,
      _C.CreatedByUser,
      _C.VATRegistration,
      _C.TaxNumber1,
      _C.TaxNumber2,
      _C.TaxNumber3,
      _C.TaxNumber4,
      _C.TaxNumber5,
      _C.VATLiability,
      _C.ResponsibleType,
      _C.TaxNumberType,
      
      //new

      _C.AddressID,
      
//      _CustomerSalesArea.SalesOffice,

//      _CustomerSalesArea.SalesGroup,

//      _CustomerSalesArea.CustomerPaymentTerms,

//      

//      _CustomerCompany.AccountingClerk as AccountingClerk,

//      _CustomerCompany.PaymentTerms,

//      _CustomerCompany.PhysicalInventoryBlockInd,

//      _CustomerCompany.CreditMemoPaymentTerms,

//      _CustomerCompany.PaymentMethodsList,

//      _CustomerCompany.HouseBank,

//      _CustomerCompany.PaymentBlockingReason,

//      _CustomerCompany.DunningNoticeGroup,

//      _CustomerCompany.AccountByCustomer,

//      _CustomerCompany.UserAtCustomer,

//      _CustomerCompany.AccountingClerkPhoneNumber,

//      _CustomerCompany.AccountingClerkInternetAddress,

//      _CustomerCompany.ReconciliationAccount,

//      _CustomerCompany.InterestCalculationCode,

//      _CustomerCompany.IntrstCalcFrequencyInMonths,

//      _CustomerCompany.InterestCalculationDate,

//      _CustomerCompany.LastInterestCalcRunDate,

//      _CustomerCompany.CustPreviousMasterRecordNumber,

//      _CustomerCompany.CashPlanningGroup,


//      //instead of exposed fields

//      _C._CustomerToBusinessPartner,

//      _C._StandardAddress,


//      //used by consumption layer

//      _CustomerCompany,

//      _CustomerSalesArea,


      //these fields are needed for DCL

      _C.DataControllerSet,
      _C.DataController1,
      _C.DataController2,
      _C.DataController3,
      _C.DataController4,
      _C.DataController5,
      _C.DataController6,
      _C.DataController7,
      _C.DataController8,
      _C.DataController9,
      _C.DataController10

}

union all

select from I_Customer as _C
      
     left outer join P_ARCustomerSalesArea as _CSA
      on _C.Customer = _CSA.Customer

     left outer to one join I_CustomerCompany as _CC
      on _C.Customer = _CC.Customer
      and _CC.CompanyCode = _CSA.CompanyCode

//select from P_ARCustomerSalesArea as _CSA

//

//  left outer to one join I_Customer as _C

//    on _C.Customer = _CSA.Customer

//      

//  left outer to one join I_CustomerCompany as _CC

//    on _C.Customer = _CC.Customer

//    and _CC.CompanyCode = _CSA.CompanyCode

  
//  association [0..1] to I_CustomerCompany as _CustomerCompany

//    on $projection.Customer = _CustomerCompany.Customer

//    and $projection.CompanyCode = _CustomerCompany.CompanyCode

//    

//  association [0..1] to I_CustomerSalesArea as _CustomerSalesArea

//    on $projection.Customer = _CustomerSalesArea.Customer

//    and $projection.SalesOrganization = _CustomerSalesArea.SalesOrganization

//    and $projection.DistributionChannel = _CustomerSalesArea.DistributionChannel

//    and $projection.Division = _CustomerSalesArea.Division


{
  key _C.Customer,
  key _CC.CompanyCode as CompanyCode,
  key _CSA.SalesOrganization as SalesOrganization,
  key _CSA.DistributionChannel as DistributionChannel,
  key _CSA.Division as Division,
  key '' as CustomerIsWithCompanyCode,
  
      _C.CustomerAccountGroup,
      _C._CustomerAccountGroupText,
      _C.Supplier,
      _C.PostingIsBlocked,
      _C.AuthorizationGroup,
      _C.CreatedByUser,
      _C.VATRegistration,
      _C.TaxNumber1,
      _C.TaxNumber2,
      _C.TaxNumber3,
      _C.TaxNumber4,
      _C.TaxNumber5,
      _C.VATLiability,
      _C.ResponsibleType,
      _C.TaxNumberType,
      
      //new

      _C.AddressID,
      
//      _CustomerSalesArea.SalesOffice,

//      _CustomerSalesArea.SalesGroup,

//      _CustomerSalesArea.CustomerPaymentTerms,

//      

//      _CustomerCompany.AccountingClerk as AccountingClerk,

//      _CustomerCompany.PaymentTerms,

//      _CustomerCompany.PhysicalInventoryBlockInd,

//      _CustomerCompany.CreditMemoPaymentTerms,

//      _CustomerCompany.PaymentMethodsList,

//      _CustomerCompany.HouseBank,

//      _CustomerCompany.PaymentBlockingReason,

//      _CustomerCompany.DunningNoticeGroup,

//      _CustomerCompany.AccountByCustomer,

//      _CustomerCompany.UserAtCustomer,

//      _CustomerCompany.AccountingClerkPhoneNumber,

//      _CustomerCompany.AccountingClerkInternetAddress,

//      _CustomerCompany.ReconciliationAccount,

//      _CustomerCompany.InterestCalculationCode,

//      _CustomerCompany.IntrstCalcFrequencyInMonths,

//      _CustomerCompany.InterestCalculationDate,

//      _CustomerCompany.LastInterestCalcRunDate,

//      _CustomerCompany.CustPreviousMasterRecordNumber,

//      _CustomerCompany.CashPlanningGroup,


//      //instead of exposed fields

//      _C._CustomerToBusinessPartner,

//      _C._StandardAddress,


//      //used by consumption layer

//      _CustomerCompany,

//      _CustomerSalesArea,


      //these fields are needed for DCL

      _C.DataControllerSet,
      _C.DataController1,
      _C.DataController2,
      _C.DataController3,
      _C.DataController4,
      _C.DataController5,
      _C.DataController6,
      _C.DataController7,
      _C.DataController8,
      _C.DataController9,
      _C.DataController10

}