P_PL_SAFTFileHeading

DDL: P_PL_SAFTFILEHEADING Type: view_entity CONSUMPTION Package: GLO_FIN_IS_SAFT_PL

SAF-T PL KR PD File Heading

P_PL_SAFTFileHeading is a Consumption CDS View that provides data about "SAF-T PL KR PD File Heading" in SAP S/4HANA. It reads from 2 data sources (I_CompanyCode, I_PL_SAFTGeneralSettings) and exposes 16 fields with key field CompanyCode. Part of development package GLO_FIN_IS_SAFT_PL.

Data Sources (2)

SourceAliasJoin Type
I_CompanyCode Company from
I_PL_SAFTGeneralSettings Settings inner

Parameters (2)

NameTypeDefault
P_StartDate datum
P_EndDate datum

Annotations (7)

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

Fields (16)

KeyFieldSource TableSource FieldDescription
KEY CompanyCode I_CompanyCode CompanyCode
AddresseeFullNameendasCompanyName
CityName1endasCompanyCodeAddress
RegionNameendelseendasRegion
StreetNameendasStreetName
HouseNumberendasHouseNumber
CityNameendasHomeCityName
PostalCodeendasPostalCode
CityName
PhoneNumber
CompanyVATRegistration
EmailAddress I_PL_SAFTGeneralSettings EmailAddress
PL_TaxOfficeCode I_PL_SAFTGeneralSettings PL_TaxOfficeCode
CompanyCodeCurrency I_CompanyCode Currency
Country I_CompanyCode Country
_Currency I_CompanyCode _Currency
@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.private: true
@VDM.viewType: #CONSUMPTION
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
  serviceQuality: #X,
  sizeCategory: #S,
  dataClass: #MIXED
}
define view entity P_PL_SAFTFileHeading  with parameters
    P_StartDate : datum,
    P_EndDate   : datum
  as select from           I_CompanyCode            as Company
    inner join             I_PL_SAFTGeneralSettings as Settings on  Settings.CompanyCode       = Company.CompanyCode
                                                                and Settings.ValidityEndDate   >= $parameters.P_StartDate
                                                                and Settings.ValidityStartDate <= $parameters.P_EndDate
    left outer to one join P_PL_SAFTCompanyCodeCountry               on Company.CompanyCode = P_PL_SAFTCompanyCodeCountry.CompanyCode
{
  key Company.CompanyCode,


      case
        when Company.Country = 'PL'
          then
            concat_with_space( concat_with_space( concat_with_space(
            Company._Address.BusinessPartnerName1,
            Company._Address.BusinessPartnerName2, 1),
            Company._Address.BusinessPartnerName3, 1),
            Company._Address.BusinessPartnerName4, 1)
        else
            P_PL_SAFTCompanyCodeCountry._Address.AddresseeFullName
        end                                                as CompanyName,

      case
          when Company.Country = 'PL'
            then
              concat_with_space(concat_with_space(concat_with_space(
              Company._Address.StreetName,
              Company._Address.HouseNumber, 1),
              Company._Address.PostalCode, 1),
              Company._Address.CityName, 1)
          else
              concat_with_space(concat_with_space(concat_with_space(
             P_PL_SAFTCompanyCodeCountry._Address.StreetName,
             P_PL_SAFTCompanyCodeCountry._Address.HouseNumber, 1),
             P_PL_SAFTCompanyCodeCountry._Address.PostalCode, 1),
             P_PL_SAFTCompanyCodeCountry._Address.CityName, 1)
          end                                           as CompanyCodeAddress,


      case
        when Company.Country = 'PL'
         then
            case
              when Company._Address.Region is initial
                then 'Nie dotyczy'
              else Company._Address._Region._RegionText[1: Language = 'L'].RegionName
             end
          when P_PL_SAFTCompanyCodeCountry._Address.Country = 'PL'
            then
            case
              when P_PL_SAFTCompanyCodeCountry._Address.Region is initial
                then 'Nie dotyczy'
              else P_PL_SAFTCompanyCodeCountry._Address._Region._RegionText[1: Language = 'L'].RegionName
             end
           else
           ''
          end                                              as Region,

      case
       when Company.Country = 'PL'
        then
           Settings.PL_CompanyDistrictName
        when P_PL_SAFTCompanyCodeCountry._Address.Country = 'PL'
              then Settings.PL_CompanyDistrictName
         else
           ''
         end                                               as PL_CompanyDistrictName,

      case
       when Company.Country = 'PL'
        then
           Settings.PL_CompanySubDistrictName
       when P_PL_SAFTCompanyCodeCountry._Address.Country = 'PL'
        then Settings.PL_CompanySubDistrictName
         else
          ''
         end                                               as PL_CompanySubDistrictName,

      case
        when Company.Country = 'PL'
          then Company._Address.StreetName
       when Company.Country <> 'PL'
          then P_PL_SAFTCompanyCodeCountry._Address.StreetName
        end                                                as StreetName,

      case
      when Company.Country = 'PL'
        then Company._Address.HouseNumber
      when Company.Country <> 'PL'
        then P_PL_SAFTCompanyCodeCountry._Address.HouseNumber
      end                                                  as HouseNumber,

      case
       when Company.Country = 'PL'
         then Company._Address.HouseNumberSupplementText
       when Company.Country <> 'PL'
         then P_PL_SAFTCompanyCodeCountry._Address.HouseNumberSupplementText
       end                                                 as HouseNumberSupplementText,

      case
       when Company.Country = 'PL'
         then
           case
             when Company._Address.HomeCityName is initial
               then Company._Address.CityName
             else Company._Address.HomeCityName
           end
        when Company.Country <> 'PL'
         then P_PL_SAFTCompanyCodeCountry._Address.CityName
       end                                                 as HomeCityName,

      case
       when Company.Country = 'PL'
         then Company._Address.PostalCode
         when Company.Country <> 'PL'
          then P_PL_SAFTCompanyCodeCountry._Address.PostalCode
         end                                               as PostalCode,

      // X means Podmiot1 and '' means Podmiot2

      case
      when Company.Country <> 'PL'
        then
          case
            when P_PL_SAFTCompanyCodeCountry._Address.Country = 'PL'
              then 'Y'
            else
               'N'
          end
      when Company.Country = 'PL'
      then 'Y'
      end                                                  as PL_IndicatorIsTrueOrFalse,


      Company._Address.CityName                            as CityName,
      Company._Address.PhoneNumber                         as PhoneNumber,
      replace(Company.VATRegistration, Company.Country,'') as CompanyVATRegistration,
      Settings.EmailAddress,
      Settings.PL_TaxOfficeCode,
      Company.Currency                                     as CompanyCodeCurrency,
      Company.Country,

      Company._Currency

}