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 C_PL_SAFTInvoiceCnsldtnHeader.
-- 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.
-- SQL view name: CPLSAFTINVOICEH
-- Parameters: P_StatutoryReportVersion : fibrrptg_layout_version_de
CREATE VIEW C_PL_SAFTInvoiceCnsldtnHeader AS
SELECT
saftn_consolidation.SAFTConsolidationUUID AS SAFTConsolidationUUID,
Currency,
FiscalYear,
AccountingDocument,
CompanyCode,
DeliveryDate,
EmailAddress,
LocalTaxOffice,
District,
CompanyRegion,
Municipality,
case when _OneTimeAccount.BusinessPartnerName1 is not initial then concat_with_space(concat_with_space(concat_with_space(_OneTimeAccount.BusinessPartnerName1,_OneTimeAccount.BusinessPartnerName2, 1), _OneTimeAccount.BusinessPartnerName3,1),_OneTimeAccount.BusinessPartnerName4,1) when Customer is not initial then concat(concat(concat_with_space(_Customer._StandardAddress.BusinessPartnerName1,_Customer._StandardAddress.BusinessPartnerName2, 1), _Customer._StandardAddress.BusinessPartnerName3),_Customer._StandardAddress.BusinessPartnerName4) else concat_with_space(concat_with_space(concat_with_space(_Supplier._StandardAddress.BusinessPartnerName1,_Supplier._StandardAddress.BusinessPartnerName2, 1), _Supplier._StandardAddress.BusinessPartnerName3,1),_Supplier._StandardAddress.BusinessPartnerName4,1) end as FullName AS BusinessPartnerName41endasFullName,
case when _OneTimeAccount.BusinessPartnerName1 is not initial then concat(concat_with_space(_OneTimeAccount.CityName,_OneTimeAccount.PostalCode, 1), _OneTimeAccount.StreetAddressName) when Customer is not initial then concat_with_space(concat_with_space(concat_with_space(_Customer._StandardAddress.CityName,_Customer._StandardAddress.PostalCode, 1), _Customer._StandardAddress.StreetName,1),_Customer._StandardAddress.HouseNumber,1) else concat_with_space(concat_with_space(concat_with_space(_Supplier._StandardAddress.CityName,_Supplier._StandardAddress.PostalCode, 1), _Supplier._StandardAddress.StreetName,1),_Supplier._StandardAddress.HouseNumber,1) end as CustomerSupplierAddress AS HouseNumber1endasCustomerSupplierAddress,
InvoiceDocumentNumber,
IsEUTriangularDeal,
IsReversed,
SDDocumentReasonText,
case when _OneTimeAccount.Country is not initial and ( _OneTimeAccount.Country = 'AT' or _OneTimeAccount.Country = 'BE' or _OneTimeAccount.Country = 'BG' or _OneTimeAccount.Country = 'CY' or _OneTimeAccount.Country = 'CZ' or _OneTimeAccount.Country = 'DE' or _OneTimeAccount.Country = 'DK' or _OneTimeAccount.Country = 'EE' or _OneTimeAccount.Country = 'ES' or _OneTimeAccount.Country = 'FI' or _OneTimeAccount.Country = 'FR' or _OneTimeAccount.Country = 'GB' or _OneTimeAccount.Country = 'GR' or _OneTimeAccount.Country = 'HU' or _OneTimeAccount.Country = 'IE' or _OneTimeAccount.Country = 'IT' or _OneTimeAccount.Country = 'LT' or _OneTimeAccount.Country = 'LU' or _OneTimeAccount.Country = 'LV' or _OneTimeAccount.Country = 'MF' or _OneTimeAccount.Country = 'MT' or _OneTimeAccount.Country = 'NL' or _OneTimeAccount.Country = 'PT' or _OneTimeAccount.Country = 'RO' or _OneTimeAccount.Country = 'SE' or _OneTimeAccount.Country = 'SI' or _OneTimeAccount.Country = 'SK' ) then _OneTimeAccount.Country when _Customer.Country is not initial and ( _Customer.Country = 'AT' or _Customer.Country = 'BE' or _Customer.Country = 'BG' or _Customer.Country = 'CY' or _Customer.Country = 'CZ' or _Customer.Country = 'DE' or _Customer.Country = 'DK' or _Customer.Country = 'EE' or _Customer.Country = 'ES' or _Customer.Country = 'FI' or _Customer.Country = 'FR' or _Customer.Country = 'GB' or _Customer.Country = 'GR' or _Customer.Country = 'HU' or _Customer.Country = 'IE' or _Customer.Country = 'IT' or _Customer.Country = 'LT' or _Customer.Country = 'LU' or _Customer.Country = 'LV' or _Customer.Country = 'MF' or _Customer.Country = 'MT' or _Customer.Country = 'NL' or _Customer.Country = 'PT' or _Customer.Country = 'RO' or _Customer.Country = 'SE' or _Customer.Country = 'SI' or _Customer.Country = 'SK' ) then _Customer.Country when _Supplier.Country is not initial and ( _Supplier.Country = 'AT' or _Supplier.Country = 'BE' or _Supplier.Country = 'BG' or _Supplier.Country = 'CY' or _Supplier.Country = 'CZ' or _Supplier.Country = 'DE' or _Supplier.Country = 'DK' or _Supplier.Country = 'EE' or _Supplier.Country = 'ES' or _Supplier.Country = 'FI' or _Supplier.Country = 'FR' or _Supplier.Country = 'GB' or _Supplier.Country = 'GR' or _Supplier.Country = 'HU' or _Supplier.Country = 'IE' or _Supplier.Country = 'IT' or _Supplier.Country = 'LT' or _Supplier.Country = 'LU' or _Supplier.Country = 'LV' or _Supplier.Country = 'MF' or _Supplier.Country = 'MT' or _Supplier.Country = 'NL' or _Supplier.Country = 'PT' or _Supplier.Country = 'RO' or _Supplier.Country = 'SE' or _Supplier.Country = 'SI' or _Supplier.Country = 'SK' ) then _Supplier.Country else '' end as CustomerSupplierCountry AS CountryelseendasCustomerSupplierCountry,
Customer,
Supplier,
SourceDocument,
DocumentDate,
PostingDate,
DocumentType,
AccountingDocumentItem,
PL_SAFTNetAmount10,
PL_SAFTTaxAmount16,
PL_SAFTNetAmount11,
PL_SAFTTaxAmount18,
PL_SAFTNetAmount12,
PL_SAFTTaxAmount20,
PL_SAFTNetAmount13,
PL_SAFTTaxAmount24,
PL_SAFTNetAmount14,
PL_SAFTTaxAmount26,
PL_SAFTNetAmount15,
PL_SAFTNetAmount17,
TotalAmountInTransactionCrcy,
ReasonCode,
concat_with_space(concat_with_space(concat_with_space(_CompanyCode._Address.BusinessPartnerName1,_CompanyCode._Address.BusinessPartnerName2, 1), _CompanyCode._Address.BusinessPartnerName3,1),_CompanyCode._Address.BusinessPartnerName4,1) as CompanyName AS BusinessPartnerName41asCompanyName,
concat_with_space(concat_with_space(concat_with_space(_CompanyCode._Address.CityName,_CompanyCode._Address.PostalCode, 1), _CompanyCode._Address.StreetName,1),_CompanyCode._Address.HouseNumber,1) as CompanyCodeAddress AS HouseNumber1asCompanyCodeAddress,
case when _CompanyCode._Address.Region is initial then 'Nie dotyczy' else _CompanyCode._Address.Region end as Region AS RegionendasRegion,
_CompanyCode._Address.CityName AS CityName,
_CompanyCode._Address.PostalCode AS PostalCode,
_CompanyCode._Address.StreetName AS StreetName,
_CompanyCode._Address.HouseNumber AS HouseNumber,
case when _CompanyCode._Address.HomeCityName is initial then _CompanyCode._Address.CityName else _CompanyCode._Address.HomeCityName end as HomeCityName AS HomeCityNameendasHomeCityName,
_CompanyCode._Address.HouseNumberSupplementText AS HouseNumberSupplementText,
_CompanyCode.VATRegistration AS CompanyVATRegistration,
replace(_CompanyCode.VATRegistration, 'PL', '') AS ReportingVATRegistration,
_CompanyCode.Currency AS CompanyCodeCurrency,
case when _OneTimeAccount.Country is not initial and ( _OneTimeAccount.Country = 'AT' or _OneTimeAccount.Country = 'BE' or _OneTimeAccount.Country = 'BG' or _OneTimeAccount.Country = 'CY' or _OneTimeAccount.Country = 'CZ' or _OneTimeAccount.Country = 'DE' or _OneTimeAccount.Country = 'DK' or _OneTimeAccount.Country = 'EE' or _OneTimeAccount.Country = 'ES' or _OneTimeAccount.Country = 'FI' or _OneTimeAccount.Country = 'FR' or _OneTimeAccount.Country = 'GB' or _OneTimeAccount.Country = 'GR' or _OneTimeAccount.Country = 'HU' or _OneTimeAccount.Country = 'IE' or _OneTimeAccount.Country = 'IT' or _OneTimeAccount.Country = 'LT' or _OneTimeAccount.Country = 'LU' or _OneTimeAccount.Country = 'LV' or _OneTimeAccount.Country = 'MF' or _OneTimeAccount.Country = 'MT' or _OneTimeAccount.Country = 'NL' or _OneTimeAccount.Country = 'PT' or _OneTimeAccount.Country = 'RO' or _OneTimeAccount.Country = 'SE' or _OneTimeAccount.Country = 'SI' or _OneTimeAccount.Country = 'SK' ) then _CompanyCode.Country when _Customer.Country is not initial and ( _Customer.Country = 'AT' or _Customer.Country = 'BE' or _Customer.Country = 'BG' or _Customer.Country = 'CY' or _Customer.Country = 'CZ' or _Customer.Country = 'DE' or _Customer.Country = 'DK' or _Customer.Country = 'EE' or _Customer.Country = 'ES' or _Customer.Country = 'FI' or _Customer.Country = 'FR' or _Customer.Country = 'GB' or _Customer.Country = 'GR' or _Customer.Country = 'HU' or _Customer.Country = 'IE' or _Customer.Country = 'IT' or _Customer.Country = 'LT' or _Customer.Country = 'LU' or _Customer.Country = 'LV' or _Customer.Country = 'MF' or _Customer.Country = 'MT' or _Customer.Country = 'NL' or _Customer.Country = 'PT' or _Customer.Country = 'RO' or _Customer.Country = 'SE' or _Customer.Country = 'SI' or _Customer.Country = 'SK' ) then _CompanyCode.Country when _Supplier.Country is not initial and ( _Supplier.Country = 'AT' or _Supplier.Country = 'BE' or _Supplier.Country = 'BG' or _Supplier.Country = 'CY' or _Supplier.Country = 'CZ' or _Supplier.Country = 'DE' or _Supplier.Country = 'DK' or _Supplier.Country = 'EE' or _Supplier.Country = 'ES' or _Supplier.Country = 'FI' or _Supplier.Country = 'FR' or _Supplier.Country = 'GB' or _Supplier.Country = 'GR' or _Supplier.Country = 'HU' or _Supplier.Country = 'IE' or _Supplier.Country = 'IT' or _Supplier.Country = 'LT' or _Supplier.Country = 'LU' or _Supplier.Country = 'LV' or _Supplier.Country = 'MF' or _Supplier.Country = 'MT' or _Supplier.Country = 'NL' or _Supplier.Country = 'PT' or _Supplier.Country = 'RO' or _Supplier.Country = 'SE' or _Supplier.Country = 'SI' or _Supplier.Country = 'SK' ) then _CompanyCode.Country else '' end as Country AS CountryelseendasCountry,
PL_SAFTHighRateTxAmtInLoclCrcy,
PL_SAFTMdmRateTxAmtInLoclCrcy,
PL_SAFTLowRateTxAmtInLoclCrcy,
PL_SAFTOthRateTxAmtInLoclCrcy,
PL_SAFTInvoiceHasSplitPayment,
PL_SAFTDownPaymentPrevInvcsTxt,
SalesDocument,
TotalGrossAmount
FROM I_PL_SAFTInvoiceHeader AS Invoice_header
INNER JOIN I_SAFTConsolidationKey AS saftn_consolidation ON /* join condition not captured in parsed metadata */
;