I_PT_SAFTDeliveryCustomer_2

DDL: I_PT_SAFTDELIVERYCUSTOMER_2 Type: view_entity COMPOSITE Package: GLO-LOG-PT

SAFT for Normal Customer

I_PT_SAFTDeliveryCustomer_2 is a Composite CDS View that provides data about "SAFT for Normal Customer" in SAP S/4HANA. It reads from 2 data sources (I_Customer, I_PT_SAFTCustPartnerFunction) and exposes 20 fields with key fields PortugueseDeliveryNumber, DeliveryDocument, CompanyCode. It has 2 associations to related views. Part of development package GLO-LOG-PT.

Data Sources (2)

SourceAliasJoin Type
I_Customer Cust inner
I_PT_SAFTCustPartnerFunction SignCust from

Associations (2)

CardinalityTargetAliasCondition
[0..1] I_PT_DelDocCustAddrHist_2 _History SignCust.Customer = _History.Customer and SignCust.DeliveryDocument = _History.DeliveryDocument
[0..1] I_SAFTCustTaxRegnNmbr _CustLand SignCust.Customer = _CustLand.CustomerNum and SignCust.Country = _CustLand.Country

Annotations (8)

NameValueLevelField
VDM.viewType #COMPOSITE view
AccessControl.authorizationCheck #MANDATORY view
Metadata.ignorePropagatedAnnotations true view
ObjectModel.usageType.sizeCategory #XL view
ObjectModel.usageType.serviceQuality #X view
ObjectModel.usageType.dataClass #MIXED view
AccessControl.personalData.blocking #REQUIRED view
EndUserText.label SAFT for Normal Customer view

Fields (20)

KeyFieldSource TableSource FieldDescription
KEY PortugueseDeliveryNumber I_PT_SAFTCustPartnerFunction PortugueseDeliveryNumber
KEY DeliveryDocument I_PT_SAFTCustPartnerFunction DeliveryDocument
KEY CompanyCode I_PT_SAFTCustPartnerFunction CompanyCode
DocumentDate I_PT_SAFTCustPartnerFunction DeliveryDate
CreationDate I_PT_SAFTCustPartnerFunction PortugueseDigitalSignatureDate
CreationTime I_PT_SAFTCustPartnerFunction PortugueseDigitalSignatureTime
Customer I_PT_SAFTCustPartnerFunction Customer
CustomerendasBusinessPartnerCustomer
CompanyNameasbu_name1txendasCompanyName
StreetNameDesconhecidoendasStreetName
CityNameDesconhecidoendasCityName
PostalCode0000000endasPostalCode
Countryendasland1asCountry
HouseNumber
Region
PhoneNumberendasPhoneNumber
FaxNumberendasFaxNumber
EmailAddressendasEmailAddress
WebsiteURLendasWebsiteURL
_DelDoc I_PT_SAFTCustPartnerFunction _DelDoc
@VDM.viewType: #COMPOSITE // #BASIC

@AccessControl.authorizationCheck:#MANDATORY
@Metadata.ignorePropagatedAnnotations:true
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.serviceQuality: #X
@ObjectModel.usageType.dataClass: #MIXED
@AccessControl.personalData.blocking: #REQUIRED
@EndUserText.label: 'SAFT for Normal Customer'

define view entity I_PT_SAFTDeliveryCustomer_2
  as select from           I_PT_SAFTCustPartnerFunction as SignCust 
    inner join             I_Customer                   as Cust                   on Cust.Customer = SignCust.Customer
    left outer to one join I_CustomerCompany            as CustomerCompany        on  SignCust.Customer    = CustomerCompany.Customer
                                                                                  and SignCust.CompanyCode = CustomerCompany.CompanyCode
    left outer to one join I_GLAccountInCompanyCode     as GLAccountInCompanyCode on  CustomerCompany.ReconciliationAccount = GLAccountInCompanyCode.GLAccount
                                                                                  and CustomerCompany.CompanyCode           = GLAccountInCompanyCode.CompanyCode
    left outer to one join I_PT_SAFTIsAlternateAccount  as Account                on Account.CompanyCode = SignCust.CompanyCode

  association [0..1] to I_PT_DelDocCustAddrHist_2 as _History  on  SignCust.Customer         = _History.Customer  
                                                              and SignCust.DeliveryDocument = _History.DeliveryDocument
  association [0..1] to I_SAFTCustTaxRegnNmbr    as _CustLand on  SignCust.Customer = _CustLand.CustomerNum
                                                              and SignCust.Country  = _CustLand.Country
{
  key  SignCust.PortugueseDeliveryNumber                                                         as PortugueseDeliveryNumber,
  key  SignCust.DeliveryDocument                                                                 as DeliveryDocument,
  key  SignCust.CompanyCode                                                                      as CompanyCode,
       SignCust.DeliveryDate                                                                     as DocumentDate,
       SignCust.PortugueseDigitalSignatureDate                                                   as CreationDate,
       SignCust.PortugueseDigitalSignatureTime                                                   as CreationTime,
       SignCust.Customer,
       case
       when _History.BusinessPartnerCustomer is not initial
       then
         case
          when _CustLand.CustomerNum is not initial
             then  concat(_History.BusinessPartnerCustomer,concat('_',SignCust.Country))
             else _History.BusinessPartnerCustomer
          end
       else
           SignCust.Customer
       end                                                                                       as BusinessPartnerCustomer, 

       //       _History.PortugueseCustomerWithVersion   as PortugueseCustomerWithVersion,


       case
       when _History.BusinessPartnerCustomer is not initial
           then _History.CustomerVATRegistration
       else
          case
            when SignCust.VATRegistration is not initial
              then substring(SignCust.VATRegistration,3,18)
            when SignCust.TaxNumber1 is not initial
              then SignCust.TaxNumber1
            when SignCust.IsOneTimeAccount is initial
              then '999999990'
           end
       end                                                                                       as CustomerVATRegistration,

       case
        when Account.AlternativeGLAccountIsUsed  is not initial
            then GLAccountInCompanyCode.AlternativeGLAccount
        else CustomerCompany.ReconciliationAccount
       end                                                                                       as ReconciliationAccount,

       case
         when _History.BusinessPartnerCustomer is not initial
            then
                cast (_History.CompanyName as bu_name1tx)
            else
               cast (SignCust.CompanyName as  bu_name1tx)
       end                                                                                       as CompanyName,

       case
        when _History.BusinessPartnerCustomer is not initial
            then
            coalesce(_History.PT_CustomerSupplierAddressText, 'Desconhecido')             
            else
            coalesce(SignCust.StreetName, 'Desconhecido')
            end                                                                                  as StreetName,

       case
        when _History.BusinessPartnerCustomer is not initial
            then
            coalesce(_History.CityName, 'Desconhecido')
            else
            coalesce(SignCust.CityName, 'Desconhecido')
       end                                                                                       as CityName,

       case
        when _History.BusinessPartnerCustomer is not initial
            then
            coalesce(_History.PostalCode, '0000-000')
            else
            coalesce(SignCust.PostalCode, '0000-000')
        end                                                                                      as PostalCode,

       cast(case
        when _History.BusinessPartnerCustomer is not initial
            then
              _History.Country
            else
              SignCust.Country
       end as land1)                                                                              as Country,

       Cust._AddressRepresentation.HouseNumber                                                   as HouseNumber,
       Cust._AddressRepresentation.Region                                                        as Region,

       case
        when Cust._AddressRepresentation.StreetName is not initial
        or   Cust._AddressRepresentation.HouseNumber is not initial
            then
            concat ( Cust._AddressRepresentation.StreetName, Cust._AddressRepresentation.HouseNumber)
            else
            'Desconhecido'
        end                                                                      as PT_ShipToPartyAddressAsText, 

       case
       when _History.BusinessPartnerCustomer is not initial
       then
       coalesce ( _History.ContactPersonName, '' )
       else
       coalesce ( SignCust.CustomerFullName, '' )
       end                                                                                       as CompanyContactPersonFullName,

       case
       when _History.BusinessPartnerCustomer is not initial
       then
        coalesce ( _History.PhoneNumber, '' )
       else
        coalesce ( SignCust.PhoneNumber, '' )
       end                                                                                       as PhoneNumber,

       case
       when _History.BusinessPartnerCustomer is not initial
       then
        coalesce ( _History.FaxNumber, '' )
       else
        coalesce ( SignCust.FaxNumber, '' )
       end                                                                                       as FaxNumber,

       case
       when _History.BusinessPartnerCustomer is not initial
       then
        coalesce ( _History.EmailAddress, '' )
       else
        coalesce ( SignCust.EmailAddress, '' )
       end                                                                                       as EmailAddress,

       case
       when _History.BusinessPartnerCustomer is not initial
       then
        coalesce ( _History.SearchURLAddress, '' )
       else
        coalesce ( SignCust.WebsiteURL, '' )
       end                                                                                       as WebsiteURL,

       SignCust._DelDoc
}
where
 SignCust.PortugueseDigitalSignature <> ''
 and SignCust.IsOneTimeAccount <> 'X'