P_PL_SAFTFileHeading is a Consumption CDS View in SAP S/4HANA. It reads from 2 data sources (I_CompanyCode, I_PL_SAFTGeneralSettings) and exposes 16 fields with key field CompanyCode.
Derived SQL interpretation, reconstructed from the parsed view metadata (data sources, associations, and field mappings). SAP annotations are omitted and the structure is reformulated as SQL — this is a functional approximation, not the verbatim SAP source.
-- Derived SQL interpretation of CDS view P_PL_SAFTFileHeading.-- Reconstructed from parsed metadata (data sources, associations, fields).-- SAP annotations are omitted and the structure is reformulated as SQL;-- this is a functional approximation, not the verbatim SAP source. Some join-- conditions may be unavailable and a few CDS constructs are kept as-is.-- Parameters: P_StartDate : datum, P_EndDate : datumCREATE VIEW P_PL_SAFTFileHeading ASSELECT
Company.CompanyCode AS 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_SAFTCompanyCodeCountry._Address.AddresseeFullName endas CompanyName AS AddresseeFullNameendasCompanyName,
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_SAFTCompanyCodeCountry._Address.StreetName, P_PL_SAFTCompanyCodeCountry._Address.HouseNumber, 1), P_PL_SAFTCompanyCodeCountry._Address.PostalCode, 1), P_PL_SAFTCompanyCodeCountry._Address.CityName, 1) endas CompanyCodeAddress AS CityName1endasCompanyCodeAddress,
casewhen Company.Country = 'PL' thencasewhen Company._Address.Region is initial then 'Nie dotyczy' elsecasewhen Company._Address._Region._RegionText[1: Language = 'L'].RegionName isnot initial then Company._Address._Region._RegionText[1: Language = 'L'].RegionName when Company._Address._Region._RegionText[1: Language = 'L'].RegionName is initial then Company._Address._Region._RegionText[1: Language = $session.system_language].RegionName else Company._Address._Region._RegionText[1: Language = 'E'].RegionName endendwhen P_PL_SAFTCompanyCodeCountry._Address.Country = 'PL' thencasewhen P_PL_SAFTCompanyCodeCountry._Address.Region is initial then 'Nie dotyczy' elsecasewhen P_PL_SAFTCompanyCodeCountry._Address._Region._RegionText[1: Language = 'L'].RegionName isnot initial then P_PL_SAFTCompanyCodeCountry._Address._Region._RegionText[1: Language = 'L'].RegionName when P_PL_SAFTCompanyCodeCountry._Address._Region._RegionText[1: Language = 'L'].RegionName is initial then P_PL_SAFTCompanyCodeCountry._Address._Region._RegionText[1: Language = $session.system_language].RegionName else P_PL_SAFTCompanyCodeCountry._Address._Region._RegionText[1: Language = 'E'].RegionName endendelse '' endas Region AS RegionNameendendelseendasRegion,
casewhen Company.Country = 'PL' then Company._Address.StreetName when Company.Country <> 'PL' then P_PL_SAFTCompanyCodeCountry._Address.StreetName endas StreetName AS StreetNameendasStreetName,
casewhen Company.Country = 'PL' then Company._Address.HouseNumber when Company.Country <> 'PL' then P_PL_SAFTCompanyCodeCountry._Address.HouseNumber endas HouseNumber AS HouseNumberendasHouseNumber,
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_SAFTCompanyCodeCountry._Address.CityName endas HomeCityName AS CityNameendasHomeCityName,
casewhen Company.Country = 'PL' then Company._Address.PostalCode when Company.Country <> 'PL' then P_PL_SAFTCompanyCodeCountry._Address.PostalCode endas PostalCode AS PostalCodeendasPostalCode,
Company._Address.CityName AS CityName,
Company._Address.PhoneNumber AS PhoneNumber,
replace(Company.VATRegistration, Company.Country,'') AS CompanyVATRegistration,
Settings.EmailAddress AS EmailAddress,
Settings.PL_TaxOfficeCode AS PL_TaxOfficeCode,
Company.Currency AS CompanyCodeCurrency,
Company.Country AS Country,
Company._Currency AS _Currency
FROM I_CompanyCode AS Company
INNERJOIN I_PL_SAFTGeneralSettings AS Settings ON /* join condition not captured in parsed metadata */
;