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 I_PT_SAFTDeliveryHeader.
-- 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: IPTSAFTDELHDR
CREATE VIEW I_PT_SAFTDeliveryHeader AS
SELECT
PortugueseDeliveryNumber,
DeliveryDocument.DeliveryDocument AS DeliveryDocument,
ShipToParty,
DigitalSignature.PortugueseDigitalSignatureDate AS CreationDate,
DigitalSignature.PortugueseDigitalSignatureTime AS CreationTime,
DigitalSignature.CompanyCode AS CompanyCode,
DigitalSignature.DeliveryDocumentType AS DeliveryDocumentType,
DigitalSignature.ReferenceDocumentNumber AS PortugueseReferenceDocument,
cast( DigitalSignature.PortugueseDgtlSignatureSeries as glo_pt_series_id) AS PT_SeriesIdentifier,
PTDgtlSgntrSystemDateTimeText,
DeliveryDocument.CreatedByUser AS CreatedByUser,
'P' AS BillingPriceSource,
PortugueseDigitalSignature,
PortugueseDgtlSgntrKeyVersion,
DeliveryDocument.TransportationPlanningDate AS TransportationPlanningDate,
DigitalSignature.PT_SeriesDocumentNumber AS PT_SeriesDocumentNumber,
PortugueseSgntrCertificate,
_DelSupplier.Supplier AS Supplier,
DigitalSignature.DeliveryDate AS DeliveryDate,
case _ShipToAddress.IsOneTimeAccount when 'X' then coalesce( _ShipToAddress._OnetimeCustomer[ PartnerFunction = 'AG' ].CityName, _ShipToAddress._OnetimeCustomer[ PartnerFunction = 'WE' ].CityName) else _ShipToAddress.CityName end as ShipToPartyCityName AS CityNameendasShipToPartyCityName,
case _ShipToAddress.IsOneTimeAccount when 'X' then coalesce( _ShipToAddress._OnetimeCustomer[ PartnerFunction = 'AG' ].Country, _ShipToAddress._OnetimeCustomer[ PartnerFunction = 'WE' ].Country) else _ShipToAddress.Country end as ShipToPartyCountry AS CountryendasShipToPartyCountry,
case _ShipToAddress.IsOneTimeAccount when 'X' then coalesce( _ShipToAddress._OnetimeCustomer[ PartnerFunction = 'AG' ].PostalCode, _ShipToAddress._OnetimeCustomer[ PartnerFunction = 'WE' ].PostalCode) else _ShipToAddress.PostalCode end as ShipToPartyPostalCode AS PostalCodeendasShipToPartyPostalCode,
case _ShipToAddress.IsOneTimeAccount when 'X' then coalesce( _ShipToAddress._OnetimeCustomer[ PartnerFunction = 'AG' ].StreetName, _ShipToAddress._OnetimeCustomer[ PartnerFunction = 'WE' ].StreetName) else _ShipToAddress.StreetName end as ShipToPartyStreetName AS StreetNameendasShipToPartyStreetName,
_ShipToAddress._Addr.HouseNumber AS ShipToPartyHouseNumber,
case _ShipToAddress.IsOneTimeAccount when 'X' then concat ( coalesce( _ShipToAddress._OnetimeCustomer[ PartnerFunction = 'AG' ].StreetName, _ShipToAddress._OnetimeCustomer[ PartnerFunction = 'WE' ].StreetName ), coalesce( _ShipToAddress._OnetimeCustomer[ PartnerFunction = 'AG' ].HouseNumber, _ShipToAddress._OnetimeCustomer[ PartnerFunction = 'WE' ].HouseNumber )) else concat ( _ShipToAddress._Addr.StreetName, _ShipToAddress._Addr.HouseNumber) end as CustAddressNumber AS HouseNumberendasCustAddressNumber,
_ShipToAddress._Addr.Region AS CustomerRegion,
_ShipFromAddress.HouseNumber AS HouseNumber,
_ShipFromAddress.StreetName AS StreetName,
_ShipFromAddress.SupplierAddress AS SupplierAddress,
_ShipFromAddress.CityName AS CityName,
_ShipFromAddress.PostalCode AS PostalCode,
_ShipFromAddress.Region AS Region,
_ShipFromAddress.Country AS Country,
concat (concat(DeliveryDocument.TransportationPlanningDate,'/'), DeliveryDocument.TransportationPlanningTime) AS TransportationPlanningTimeZone,
cast( round(_AmountTotals.TotalTaxAmount, 2) as abap.dec(11,2) ) AS TotalTaxAmount,
cast( round(_AmountTotals.TotalNetAmount, 2) as abap.dec(11,2) ) AS TotalNetAmount,
round(( round(_AmountTotals.TotalTaxAmount, 2) + round(_AmountTotals.TotalNetAmount, 2)), 2) AS TotalGrossAmount,
_TotalForeignCurrency.InvoiceAmountInFrgnCurrency AS InvoiceAmountInFrgnCurrency,
DeliveryDocument.GoodsIssueTime AS GoodsIssueTime,
case when DeliveryDocument._SalesOrganization._CompanyCode.Currency <> _DelSupplier.TransactionCurrency then abs(_DelSupplier.ExchangeRate) else 0 end as ExchangeRate AS ExchangeRateelse0endasExchangeRate
FROM I_PT_DeliveryDgtlSgntr AS DigitalSignature
INNER JOIN I_DeliveryDocument AS DeliveryDocument ON /* join condition not captured in parsed metadata */
LEFT OUTER JOIN I_PT_DeliveryNumberRange AS _MovementType ON _MovementType.CompanyCode = DigitalSignature.CompanyCode AND _MovementType.DeliveryDocumentType = DigitalSignature.DeliveryDocumentType -- association [0..1]
LEFT OUTER JOIN I_PT_DeliveryShipFromAddress AS _ShipFromAddress ON _ShipFromAddress.DeliveryDocument = DeliveryDocument -- association [0..1]
LEFT OUTER JOIN I_PT_SAFTDeliveryCustDetail AS _ShipToAddress ON _ShipToAddress.PortugueseDeliveryNumber = DigitalSignature.PortugueseDeliveryNumber -- association [0..*]
LEFT OUTER JOIN I_PT_SDDocumentProcessFlow AS _SDDocumentProcessFlow ON _SDDocumentProcessFlow.DeliveryDocument = DeliveryDocument -- association [0..1]
LEFT OUTER JOIN I_PT_SAFTHeaderGrossTotal AS _TotalForeignCurrency ON _TotalForeignCurrency.PortugueseDeliveryNumber = PortugueseDeliveryNumber -- association [0..1]
LEFT OUTER JOIN I_PT_SAFTDeliveryHeaderAmt AS _AmountTotals ON _AmountTotals.PortugueseDeliveryNumber = PortugueseDeliveryNumber -- association [1..1]
LEFT OUTER JOIN I_SAFTDeliverySupplier AS _DelSupplier ON _DelSupplier.PortugueseDeliveryNumber = PortugueseDeliveryNumber -- association [0..1]
;