P_PL_SAFTInvoiceFileHeading is a Consumption CDS View that provides data about "SAF-T PL Invoice File Heading data" in SAP S/4HANA. It reads from 2 data sources (I_CompanyCode, I_PL_SAFTGeneralSettings) and exposes 15 fields with key field CompanyCode. Part of development package GLO_FIN_IS_SAFT_PL.
@AbapCatalog.sqlViewName: 'PPLSAFTINVFILEH'
@AbapCatalog.compiler.compareFilter: true@AbapCatalog.preserveKey: true@AccessControl.authorizationCheck: #CHECK@VDM.private: true@VDM.viewType: #CONSUMPTION@ObjectModel.usageType.sizeCategory: #XL@ObjectModel.usageType.dataClass: #MIXED@ObjectModel.usageType.serviceQuality: #P@ClientHandling.algorithm: #SESSION_VARIABLEdefineview P_PL_SAFTInvoiceFileHeading
withparameters
P_StartDate : datum,
P_EndDate : datum
asselectfrom I_CompanyCode as Company
innerjoin I_PL_SAFTGeneralSettings as Settings on Settings.CompanyCode = Company.CompanyCode
and Settings.ValidityEndDate >= $parameters.P_StartDate
and Settings.ValidityStartDate <= $parameters.P_EndDate
leftouter to one join P_PL_SAFTCoCodeCountry on Company.CompanyCode = P_PL_SAFTCoCodeCountry.CompanyCode
{
key Company.CompanyCode,
casewhen 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_SAFTCoCodeCountry._Address.AddresseeFullName
endas CompanyName,
casewhen 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_SAFTCoCodeCountry._Address.StreetName,
P_PL_SAFTCoCodeCountry._Address.HouseNumber, 1),
P_PL_SAFTCoCodeCountry._Address.PostalCode, 1),
P_PL_SAFTCoCodeCountry._Address.CityName, 1)
endas CompanyCodeAddress,
casewhen Company.Country = 'PL'
thencasewhen Company._Address.Region is initial
then 'Nie dotyczy'
else Company._Address._Region._RegionText[1: Language = 'L'].RegionName
endwhen P_PL_SAFTCoCodeCountry._Address.Country = 'PL'
thencasewhen P_PL_SAFTCoCodeCountry._Address.Region is initial
then 'Nie dotyczy'
else P_PL_SAFTCoCodeCountry._Address._Region._RegionText[1: Language = 'L'].RegionName
endelse
''
endas Region,
casewhen Company.Country = 'PL'
then
Settings.PL_CompanyDistrictName
when P_PL_SAFTCoCodeCountry._Address.Country = 'PL'
then Settings.PL_CompanyDistrictName
else
''
endas PL_CompanyDistrictName,
casewhen Company.Country = 'PL'
then
Settings.PL_CompanySubDistrictName
when P_PL_SAFTCoCodeCountry._Address.Country = 'PL'
then Settings.PL_CompanySubDistrictName
else
''
endas PL_CompanySubDistrictName,
casewhen Company.Country = 'PL'
then Company._Address.StreetName
when Company.Country <> 'PL'
then P_PL_SAFTCoCodeCountry._Address.StreetName
endas StreetName,
casewhen Company.Country = 'PL'
then Company._Address.HouseNumber
when Company.Country <> 'PL'
then P_PL_SAFTCoCodeCountry._Address.HouseNumber
endas HouseNumber,
casewhen Company.Country = 'PL'
then Company._Address.HouseNumberSupplementText
when Company.Country <> 'PL'
then P_PL_SAFTCoCodeCountry._Address.HouseNumberSupplementText
endas HouseNumberSupplementText,
casewhen Company.Country = 'PL'
thencasewhen Company._Address.HomeCityName is initial
then Company._Address.CityName
else Company._Address.HomeCityName
endwhen Company.Country <> 'PL'
then P_PL_SAFTCoCodeCountry._Address.CityName
endas HomeCityName,
casewhen Company.Country = 'PL'
then Company._Address.PostalCode
when Company.Country <> 'PL'
then P_PL_SAFTCoCodeCountry._Address.PostalCode
endas PostalCode,
// X means Podmiot1 and '' means Podmiot2
casewhen Company.Country <> 'PL'
thencasewhen P_PL_SAFTCoCodeCountry._Address.Country = 'PL'
then 'Y'
else
'N'
endwhen Company.Country = 'PL'
then 'Y'
endas PL_IndicatorIsTrueOrFalse,
Company._Address.CityName as CityName,
Company._Address.PhoneNumber as PhoneNumber,
casewhen Company.Country = 'PL'
then
replace(Company.VATRegistration, Company.Country,'')
else
replace(P_PL_SAFTCoCodeCountry.VATRegistration, P_PL_SAFTCoCodeCountry.VATRegistrationCountry, '' )
endas CompanyVATRegistration,
Settings.EmailAddress,
Settings.PL_TaxOfficeCode,
Company.Currency as CompanyCodeCurrency,
Company.Country,
_Currency
}