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_LU_SAFTJournalItemBP.
-- 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: PLUSAFTJIBP
CREATE VIEW P_LU_SAFTJournalItemBP AS
SELECT
JournalLineItem.CompanyCode AS CompanyCode,
JournalLineItem.Ledger AS Ledger,
JournalLineItem.FiscalYear AS FiscalYear,
BP.BusinessPartner AS BusinessPartner,
'0001' AS BusinessPartnerType,
JournalLineItem.AccountingDocument AS AccountingDocument,
JournalLineItem.LedgerGLLineItem AS LedgerGLLineItem,
JournalLineItem.PostingDate AS PostingDate,
JournalLineItem.AccountingDocumentCategory AS AccountingDocumentCategory,
JournalLineItem.AccountingDocumentItem AS AccountingDocumentItem,
cast(concat(JournalLineItem.CompanyCode, concat('_', JournalLineItem.GLAccount)) as abap.char(70)) AS SAFTGeneralLedgerAccountID,
Customer.IsOneTimeAccount AS IsOneTimeAccount,
Customer.AuthorizationGroup AS AuthorizationGroup,
Customer.TaxNumber1 AS TaxNumber1,
Customer.TaxNumber2 AS TaxNumber2,
JournalLineItem.DelivOfGoodsDestCountry AS DelivOfGoodsDestCountry,
JournalLineItem.GLAccount AS GLAccount,
JournalLineItem.ChartOfAccounts AS ChartOfAccounts,
Customer.Customer AS Customer,
cast('' as abap.char(10)) AS Supplier,
JournalLineItem.CompanyCodeCountry AS CompanyCodeCountry,
BPAddress.AddressID AS AddressID,
case when Customer.IsOneTimeAccount is initial then concat( concat( BPAddress.BusinessPartnerName1, ' '), BPAddress.BusinessPartnerName2 ) else case when OneTimeBP.TaxID1 is initial and JournalLineItem.VATRegistration is initial then concat( concat( BPAddress.BusinessPartnerName1, ' '), BPAddress.BusinessPartnerName2 ) else concat( concat( OneTimeBP.BusinessPartnerName1, ' '), OneTimeBP.BusinessPartnerName2 ) end end as CompanyName AS BusinessPartnerName2endendasCompanyName,
case when Customer.IsOneTimeAccount is initial then BPAddress.StreetName else case when OneTimeBP.TaxID1 is initial and JournalLineItem.VATRegistration is initial then BPAddress.StreetName else OneTimeBP.StreetAddressName end end as StreetName AS StreetAddressNameendendasStreetName,
case when Customer.IsOneTimeAccount is initial then BPAddress.HouseNumber else '' end as HouseNumber AS HouseNumberelseendasHouseNumber,
case when Customer.IsOneTimeAccount is initial then BPAddress.CityName else case when OneTimeBP.TaxID1 is initial and JournalLineItem.VATRegistration is initial then BPAddress.CityName else OneTimeBP.CityName end end as CityName AS CityNameendendasCityName,
case when Customer.IsOneTimeAccount is initial then BPAddress.PostalCode else case when OneTimeBP.TaxID1 is initial and JournalLineItem.VATRegistration is initial then BPAddress.PostalCode else OneTimeBP.PostalCode end end as PostalCode AS PostalCodeendendasPostalCode,
case when Customer.IsOneTimeAccount is initial then BPAddress.Region else case when OneTimeBP.TaxID1 is initial and JournalLineItem.VATRegistration is initial then BPAddress.Region else OneTimeBP.Region end end as Region AS RegionendendasRegion,
case when Customer.IsOneTimeAccount is initial then BPAddress.Country else case when OneTimeBP.TaxID1 is initial and JournalLineItem.VATRegistration is initial then BPAddress.Country else OneTimeBP.Country end end as Country AS CountryendendasCountry,
cast('' as abap.char(45)) AS SupplierToPartner,
JournalLineItem._CompanyCode AS _CompanyCode,
JournalLineItem._FiscalYear AS _FiscalYear,
JournalLineItem._Ledger AS CompanyCodeasCompanyCode,
'' AS BusinessPartnerCustomer,
cast(case when Supplier.IsOneTimeAccount is initial then case when JournalLineItem.DelivOfGoodsDestCountry = JournalLineItem.CompanyCodeCountry then concat(JournalLineItem.CompanyCode, concat ('_' , concat(Supplier.Supplier, concat('_', JournalLineItem.GLAccount)))) else concat(JournalLineItem.CompanyCode, concat ('_' , concat(Supplier.Supplier, concat('/' , concat(JournalLineItem.DelivOfGoodsDestCountry, concat('_', JournalLineItem.GLAccount)))))) end else case when OneTimeBP.TaxID1 is not initial then concat(JournalLineItem.CompanyCode, concat ('_' , concat(Supplier.Supplier, concat('/', OneTimeBP.TaxID1)))) else case when JournalLineItem.VATRegistration is not initial then concat(JournalLineItem.CompanyCode, concat ('_' , concat(Supplier.Supplier, concat('/', JournalLineItem.VATRegistration)))) else concat(JournalLineItem.CompanyCode, concat ('_' , concat(Supplier.Supplier, concat('/', '999999990')))) end end end as abap.char(35)) as SupplierToPartner AS char35asSupplierToPartner,
JournalLineItem._Ledger AS _Ledger
FROM I_LU_SAFTJournalEntry AS JournalLineItem
INNER JOIN I_BusinessPartner AS BP ON /* join condition not captured in parsed metadata */
INNER JOIN P_BPCurrentAddress AS BPAddress ON /* join condition not captured in parsed metadata */
INNER JOIN I_Customer AS Customer ON /* join condition not captured in parsed metadata */
INNER JOIN I_SupplierToBusinessPartner AS SupToBP ON /* join condition not captured in parsed metadata */
INNER JOIN I_Supplier AS Supplier ON /* join condition not captured in parsed metadata */
-- UNION with additional select branch(es): I_LU_SAFTJournalEntry
;