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_MX_JrnlEntrItmPaytDetailsC.
-- 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_AlternativeGLAccount : figlmx_prim, P_Ledger : fins_ledger, P_FiscalYear : fis_gjahr_no_conv, P_FromPostingDate : fis_budat_from, P_ToPostingDate : fis_budat_to
CREATE VIEW C_MX_JrnlEntrItmPaytDetailsC AS
SELECT
JournalEntryItem.SourceLedger AS SourceLedger,
JournalEntryItem.Ledger AS Ledger,
JournalEntryItem.CompanyCode AS CompanyCode,
JournalEntryItem.AccountingDocument AS AccountingDocument,
P_MX_JrnlEntryDistinctGLAcct.GLAccount AS GLAccount,
P_MX_JrnlEntryDistinctGLAcct.DocumentItemText AS DocumentItemText,
JournalEntryItem.FiscalYear AS FiscalYear,
StatryRptgEntity,
StatryRptCategory,
StatryRptRunID,
JournalEntryItem.AccountingDocumentItem AS AccountingDocumentItem,
JournalEntryItem.PostingDate AS PostingDate,
Check.OutgoingCheque AS OutgoingCheque,
cast( case when JournalEntryItem.TransactionCode = 'FBCJ' or ( Proposal.ExchangeRate is null and JournalEntryItem.TransactionCurrency <> 'MXN' ) then JournalEntryItem.ExchangeRate when Proposal.PaymentCurrency <> 'MXN' and ( Proposal.PaymentCurrency is not null or Proposal.PaymentCurrency <> '' ) then Proposal.ExchangeRate else 0 end as abap.dec(9,5) ) as ExchangeRate AS dec95asExchangeRate,
cast( case when JournalEntryItem.FinancialAccountType = 'K' and (Proposal.PayeeBankAccount is not null or Proposal.PayeeBankAccount <> '') and ( JournalEntryItem.Cheque is null or JournalEntryItem.Cheque = '' ) then Proposal.BankAccount when JournalEntryItem.FinancialAccountType = 'D' and (Proposal.PayeeBankAccount is not null or Proposal.PayeeBankAccount <> '') and ( JournalEntryItem.Cheque is null or JournalEntryItem.Cheque = '' ) then Proposal.PayeeBankAccount when JournalEntryItem.FinancialAccountType = 'D' and (Proposal.PayeeBankAccount is null or Proposal.PayeeBankAccount = '') then JournalEntryItem.BankAccount when JournalEntryItem.FinancialAccountType = 'K' and (Proposal.BankAccount is null or Proposal.BankAccount = '') then Payments.BankAccount else '' end as ubknt ) as BankAccount AS BankAccountelseendasubkntasBankAccount,
cast( case when JournalEntryItem.FinancialAccountType = 'K' and Proposal.BankCountry is not null then case when Proposal.BankCountry = 'MX' then substring(Proposal.Bank, 1, 3) when Proposal.BankCountry <> 'MX' and Proposal.BankCountry <> '' and Proposal.BankCountry is not null then '999' else '' end when JournalEntryItem.FinancialAccountType = 'K' and Proposal.BankCountry is null and Payments.BankCountry is not null then case when Payments.BankCountry = 'MX' then substring(Bank.Bank, 1, 3) when Payments.BankCountry <> 'MX' and Payments.BankCountry <> '' and Payments.BankCountry is not null then '999' else '' end when JournalEntryItem.FinancialAccountType = 'D' and Proposal.PayeeBankCountry is not null then case when Proposal.PayeeBankCountry = 'MX' then substring(Proposal.PayeeBank, 1, 3) when Proposal.PayeeBankCountry <> 'MX' and Proposal.PayeeBankCountry <> '' and Proposal.PayeeBankCountry is not null then '999' else '' end when JournalEntryItem.FinancialAccountType = 'D' and Proposal.PayeeBankCountry is null then JournalEntryItem.Bank else '' end as ubnkl ) as Bank AS BankelseendasubnklasBank,
cast( case when ExtPaymentMethodMapping.MX_ExternalPaymentMethod = '03' and Proposal.BankCountry <> 'MX' then Proposal._Bank.BankName else '' end as banka ) as BankName AS BankNameelseendasbankaasBankName,
cast( case when ExtPaymentMethodMapping.MX_ExternalPaymentMethod = '03' and Proposal.PayeeBankCountry <> 'MX' then Proposal._PayeeBank.BankName else '' end as banka ) as PayeeBankName AS BankNameelseendasbankaasPayeeBankName,
JournalEntryItem.OrganizationBPName1 AS OrganizationBPName1,
JournalEntryItem.TaxNumber1 AS TaxNumber1,
Proposal.HouseBankAccount AS HouseBankAccount,
Proposal.PaymentRecipient AS PaymentRecipient,
Proposal._PaymentMethod.PaymentMethodIsUsedForCheck AS PaymentMethodIsUsedForCheck,
Proposal._PaymentMethod.PaytMethIsUsdForBillOfExchange AS PaytMethIsUsdForBillOfExchange,
Proposal._PaymentMethod.PaytMethIsUsdForChkBillOfExch AS PaytMethIsUsdForChkBillOfExch,
JournalEntryItem.PaymentMethod AS PaymentMethod,
JournalEntryItem.TransactionCode AS TransactionCode,
'' AS LedgerGLLineItem
FROM P_MX_JrnlEntrItmPaytDetailsC
INNER JOIN P_MX_JrnlEntryDistinctGLAcct ON /* join condition not captured in parsed metadata */
INNER JOIN P_MX_JournalEntryPaymentItem AS Payments ON /* join condition not captured in parsed metadata */
;