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_POItemDwnPaytCalc1.
-- 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: PMMPOIDPCALC1
-- Parameters: P_DisplayCurrency : displaycurrency
CREATE VIEW P_POItemDwnPaytCalc1 AS
SELECT
PurchaseOrderhistory.PurchaseOrder AS PurchaseOrder,
PurchaseOrderhistory.PurchaseOrderItem AS PurchaseOrderItem,
PurchaseOrderhistory.AccountAssignmentNumber AS AccountAssignmentNumber,
PurchaseOrderhistory.PurchaseOrderTransactionType AS PurchaseOrderTransactionType,
PurchaseOrderhistory.MaterialDocumentYear AS MaterialDocumentYear,
PurchaseOrderhistory.MaterialDocument AS MaterialDocument,
cast(PurchaseOrderhistory.MaterialDocumentItem as abap.char( 4 )) AS MaterialDocumentItem,
_bseg.AmountInTransactionCurrency AS AmountInTransactionCurrency,
DebitCreditCode,
case when PurchaseOrderTransactionType = 'A' and _bseg.ClearingAccountingDocument = ' ' and _bseg.AmountInTransactionCurrency is not initial then case when _bseg.xanet = '' then case when DebitCreditCode = 'H' then cast(currency_conversion( amount => _bseg.AmountInTransactionCurrency, source_currency => _bseg.TransactionCurrency, round => 'X', target_currency => $parameters.P_DisplayCurrency, exchange_rate_date => PostingDate, error_handling => 'SET_TO_NULL' ) as abap.curr(15,2)) else -1* cast (currency_conversion( amount => _bseg.AmountInTransactionCurrency, source_currency => _bseg.TransactionCurrency, round => 'X', target_currency => $parameters.P_DisplayCurrency, exchange_rate_date => PostingDate, error_handling => 'SET_TO_NULL' ) as abap.curr(15,2) ) end else cast(currency_conversion( amount => _bseg.GrossAmtInTransactionCurrency, source_currency => _bseg.TransactionCurrency, round => 'X', target_currency => $parameters.P_DisplayCurrency, exchange_rate_date => PostingDate, error_handling => 'SET_TO_NULL' ) as abap.curr(15,2)) end end as NetAmount AS curr152endendasNetAmount,
case when PurchaseOrderTransactionType = '4' and _bseg.AmountInTransactionCurrency is not initial then case when _bseg.xanet = '' then cast(currency_conversion( amount => _bseg.AmountInTransactionCurrency, source_currency => _bseg.TransactionCurrency, round => 'X', target_currency => $parameters.P_DisplayCurrency, exchange_rate_date => PostingDate, error_handling => 'SET_TO_NULL' ) as abap.curr(15,2)) else cast(currency_conversion( amount => _bseg.GrossAmtInTransactionCurrency, source_currency => _bseg.TransactionCurrency, round => 'X', target_currency => $parameters.P_DisplayCurrency, exchange_rate_date => PostingDate, error_handling => 'SET_TO_NULL' ) as abap.curr(15,2)) end end as NetValue AS curr152endendasNetValue,
case when PurchaseOrderTransactionType = 'A' and _bseg.ClearingAccountingDocument = ' ' and _bseg.AmountInTransactionCurrency is not initial then case when _bseg.xanet = '' then case when DebitCreditCode = 'H' then cast(currency_conversion( amount => _bseg.AmountInTransactionCurrency, source_currency => _bseg.TransactionCurrency, round => 'X', target_currency => I_PurchaseOrderItem.DocumentCurrency, exchange_rate_date => PostingDate, error_handling => 'SET_TO_NULL' ) as abap.curr(15,2)) else -1* cast (currency_conversion( amount => _bseg.AmountInTransactionCurrency, source_currency => _bseg.TransactionCurrency, round => 'X', target_currency => I_PurchaseOrderItem.DocumentCurrency, exchange_rate_date => PostingDate, error_handling => 'SET_TO_NULL' ) as abap.curr(15,2) ) end else cast(currency_conversion( amount => _bseg.GrossAmtInTransactionCurrency, source_currency => _bseg.TransactionCurrency, round => 'X', target_currency => I_PurchaseOrderItem.DocumentCurrency, exchange_rate_date => PostingDate, error_handling => 'SET_TO_NULL' ) as abap.curr(15,2)) end end as NetAmountDocCurrency AS curr152endendasNetAmountDocCurrency,
case when PurchaseOrderTransactionType = '4' and _bseg.AmountInTransactionCurrency is not initial then case when _bseg.xanet = '' then cast(currency_conversion( amount => _bseg.AmountInTransactionCurrency, source_currency => _bseg.TransactionCurrency, round => 'X', target_currency => I_PurchaseOrderItem.DocumentCurrency, exchange_rate_date => PostingDate, error_handling => 'SET_TO_NULL' ) as abap.curr(15,2)) else cast(currency_conversion( amount => _bseg.GrossAmtInTransactionCurrency, source_currency => _bseg.TransactionCurrency, round => 'X', target_currency => I_PurchaseOrderItem.DocumentCurrency, exchange_rate_date => PostingDate, error_handling => 'SET_TO_NULL' ) as abap.curr(15,2)) end end as NetValueDocCurrency AS curr152endendasNetValueDocCurrency
FROM I_PurchaseOrderHistory AS PurchaseOrderhistory
INNER JOIN I_PurchaseOrderItem ON /* join condition not captured in parsed metadata */
LEFT OUTER JOIN P_PODOWNPAYTBSEG AS _bseg ON I_PurchaseOrderItem.CompanyCode = _bseg.CompanyCode AND PurchaseOrderhistory.MaterialDocument = _bseg.AccountingDocument AND PurchaseOrderhistory.MaterialDocumentYear = _bseg.FiscalYear AND PurchaseOrderhistory.MaterialDocumentItem = _bseg.MaterialDocumentItem AND _bseg.FinancialAccountType = 'K' -- association [1..1]
;