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_ID_StRpVATOut.
-- 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: CIDSRVATOUT
CREATE VIEW C_ID_StRpVATOut AS
SELECT
I_AccountingDocument.CompanyCode AS CompanyCode,
I_AccountingDocument.FiscalYear AS FiscalYear,
I_AccountingDocument.AccountingDocument AS AccountingDocument,
_TaxItem.TaxBoxStrucValidityStartDate AS TaxBoxStrucValidityStartDate,
_TaxItem.TaxBoxStructureType AS TaxBoxStructureType,
AccountingDocumentType,
ReferenceDocumentType,
_AccDocCust.BusinessPlace AS BusinessPlace,
ltrim( FiscalPeriod, '0') AS FiscalPeriod,
concat(substring(DocumentDate, 7, 2),concat('/', concat(substring(DocumentDate, 5, 2),concat('/', substring(DocumentDate, 1, 4))))) AS DocumentDate,
PostingDate,
TransactionCode,
substring(DocumentReferenceID, 4, 16) AS DocumentReferenceID,
substring(OriginalReferenceDocument, 1, 10) AS BillingDocument,
Customer,
_Customer.VATRegistration AS VATRegistration,
replace(replace( _Customer.TaxNumber1, '.', '' ),'-','') AS TaxNumber1,
replace(_Customer.CustomerName, ',', ' ' ) AS CustomerName,
replace(concat_with_space( concat_with_space( concat_with_space( concat_with_space(_Customer._AddressRepresentation.HouseNumber, _Customer.CityName, 1), _Customer._AddressRepresentation.Region, 1), _Customer._AddressRepresentation.PostalCode, 1), _Customer.Country,1), ',', ' ' ) AS AddressLine1,
case when _Customer.TaxNumber1 != '' then concat(concat('"', _Customer.TaxNumber1),'"') else '' end AS BPTaxNumber,
case when _Customer.CustomerName != '' then concat(concat('"', _Customer.CustomerName),'"') else '' end AS CustomerFullName,
case when (_Customer._AddressRepresentation.HouseNumber = '' and _Customer.CityName = '' and _Customer._AddressRepresentation.Region = '' and _Customer._AddressRepresentation.PostalCode = '' and _Customer.Country = '') then '' else concat_with_space( concat_with_space( concat_with_space( concat_with_space(_Customer._AddressRepresentation.HouseNumber, _Customer.CityName, 1), _Customer._AddressRepresentation.Region, 1), _Customer._AddressRepresentation.PostalCode, 1), _Customer.Country,1) end AS AddressLine2,
case when _Customer._AddressRepresentation.DistrictName != '' then concat(concat('"', _Customer._AddressRepresentation.DistrictName),'"') else '' end AS District,
_Customer._AddressRepresentation.Building AS Building,
case when _Customer._AddressRepresentation.HouseNumber != '' then concat(concat('"', _Customer._AddressRepresentation.HouseNumber),'"') else '' end AS HouseNumber,
case when _Customer._AddressRepresentation.HouseNumberSupplementText != '' then concat(concat('"', _Customer._AddressRepresentation.HouseNumberSupplementText),'"') else '' end AS HouseNumberSupplementText,
case when _Customer._AddressRepresentation.StreetName != '' then concat(concat('"', _Customer._AddressRepresentation.StreetName),'"') else '' end AS StreetName,
case when _Customer._AddressRepresentation.StreetName != '' then concat(concat('"', _Customer._AddressRepresentation.StreetName),'"') else '' end AS StreetPrefixName,
case when _Customer._AddressRepresentation.StreetName != '' then concat(concat('"', _Customer._AddressRepresentation.StreetName),'"') else '' end AS AdditionalStreetPrefixName,
_Customer._AddressRepresentation.StreetName AS StreetSuffixName,
case when _Customer._AddressRepresentation.CityName != '' then concat(concat('"', _Customer._AddressRepresentation.CityName),'"') else '' end AS CityName,
case when _Customer._AddressRepresentation.Region != '' then concat(concat('"', _Customer._AddressRepresentation.Region),'"') else '' end AS Region,
case when _Customer._AddressRepresentation.PostalCode != '' then concat(concat('"', _Customer._AddressRepresentation.PostalCode),'"') else '' end AS PostalCode,
CompanyCodeCurrency,
abs(_TaxItem.TaxableAmount) AS TaxableAmount,
abs(_TaxItem.TaxAmount) AS TaxAmount,
abs(_TaxItem.LuxuryTaxAmt) AS LuxuryTaxAmt,
abs(_TaxItem.DownPaytTaxableAmt) AS DownPaytTaxableAmt,
abs(_TaxItem.DownPaymentTaxAmount) AS DownPaymentTaxAmount,
abs(_TaxItem.LuxuryTaxDownPaytAmt) AS LuxuryTaxDownPaytAmt
FROM I_AccountingDocument
INNER JOIN I_AcctDocCustomer AS _AccDocCust ON /* join condition not captured in parsed metadata */
LEFT OUTER JOIN I_Customer AS _Customer ON Customer = _Customer.Customer -- association [0..1]
LEFT OUTER JOIN I_ID_StRpTaxItemGrp AS _TaxItem ON CompanyCode = _TaxItem.CompanyCode AND FiscalYear = _TaxItem.FiscalYear AND AccountingDocument = _TaxItem.AccountingDocument -- association [1..1]
;