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_PH_SuplrCustJournalCube.
-- 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: IPHSCJRNLCUBE
-- Parameters: P_CompanyCode : fis_bukrs, P_FinancialAccountType : koart
CREATE VIEW I_PH_SuplrCustJournalCube AS
SELECT
SuplrCustJournalAmount.CompanyCode AS CompanyCode,
SuplrCustJournalAmount.AccountingDocument AS AccountingDocument,
SuplrCustJournalAmount.FiscalYear AS FiscalYear,
SuplrCustJournalAmount.Creditor AS Supplier,
SuplrCustJournalAmount.Debtor AS Customer,
SuplrCustJournalAmount.FiscalPeriod AS FiscalPeriod,
case when SuplrCustJournalAmount.Creditor != '' then coalesce(concat_with_space(concat_with_space(concat_with_space(OneTimeAccountBP.OneTimeAccountBPSalutationText ,OneTimeAccountBP.BusinessPartnerName1 , 1) , OneTimeAccountBP.BusinessPartnerName2 , 1) , OneTimeAccountBP.BusinessPartnerName3 , 1) ,Supplier.BPSupplierName ) else coalesce(concat_with_space(concat_with_space(concat_with_space(OneTimeAccountBP.OneTimeAccountBPSalutationText ,OneTimeAccountBP.BusinessPartnerName1 , 1) , OneTimeAccountBP.BusinessPartnerName2 , 1) , OneTimeAccountBP.BusinessPartnerName3 , 1) ,Customer.BPCustomerName ) end as BusinessPartnerName AS BPCustomerNameendasBusinessPartnerName,
case when SuplrCustJournalAmount.Creditor != '' then cast(coalesce(concat(concat(concat(concat(OneTimeAccountBP.StreetAddressName, ','), concat(OneTimeAccountBP.CityName, ',')), concat(OneTimeAccountBP.Country, ',')), OneTimeAccountBP.PostalCode), concat(concat(concat(concat(concat_with_space(concat_with_space(concat_with_space(concat_with_space(concat_with_space(Supplier._AddressRepresentation.HouseNumber, Supplier._AddressRepresentation.StreetPrefixName1, 1), Supplier._AddressRepresentation.StreetPrefixName2, 1), Supplier._AddressRepresentation.StreetName, 1), Supplier._AddressRepresentation.StreetSuffixName1, 1), Supplier._AddressRepresentation.StreetSuffixName2, 1), ','), concat(Supplier._AddressRepresentation.CityName, ',')), concat(Supplier._AddressRepresentation.Country, ',')),Supplier._AddressRepresentation.PostalCode)) as fiph_addr) else cast(coalesce(concat(concat(concat(concat(OneTimeAccountBP.StreetAddressName, ','), concat(OneTimeAccountBP.CityName, ',')), concat(OneTimeAccountBP.Country, ',')), OneTimeAccountBP.PostalCode), concat(concat(concat(concat(concat_with_space(concat_with_space(concat_with_space(concat_with_space(concat_with_space(Customer._AddressRepresentation.HouseNumber, Customer._AddressRepresentation.StreetPrefixName1, 1), Customer._AddressRepresentation.StreetPrefixName2, 1), Customer._AddressRepresentation.StreetName, 1), Customer._AddressRepresentation.StreetSuffixName1, 1), Customer._AddressRepresentation.StreetSuffixName2, 1), ','), concat(Customer._AddressRepresentation.CityName, ',')), concat(Customer._AddressRepresentation.Country, ',')),Customer._AddressRepresentation.PostalCode)) as fiph_addr) end as AddressID AS PostalCodeasfiph_addrendasAddressID,
case when SuplrCustJournalAmount.Creditor != '' then case when OneTimeAccountBP.TaxID3 != '' or Supplier.TaxNumber3 !='' then coalesce(OneTimeAccountBP.TaxID3, Supplier.TaxNumber3) else coalesce(OneTimeAccountBP.TaxID1, Supplier.TaxNumber1) end else case when OneTimeAccountBP.TaxID3 != '' or Customer.TaxNumber3 !='' then coalesce(OneTimeAccountBP.TaxID3, Customer.TaxNumber3) else coalesce(OneTimeAccountBP.TaxID1, Customer.TaxNumber1) end end as VATRegistration AS TaxNumber1endendasVATRegistration,
SuplrCustJournalAmount.AccountingDocumentType AS AccountingDocumentType,
SuplrCustJournalAmount.DocumentDate AS DocumentDate,
SuplrCustJournalAmount.PostingDate AS PostingDate,
SuplrCustJournalAmount.FinancialAccountType AS FinancialAccountType,
left(AccountingDocument.OriginalReferenceDocument,10) AS OriginalReferenceDocument,
PH_BSET_GLO.TaxCode AS TaxCode,
PH_BSET_GLO.TaxRate AS TaxRate,
PH_BSET_GLO.TaxRateValidityStartDate AS TaxRateValidityStartDate,
SuplrCustJournalAmount.CompanyCodeCurrency AS CompanyCodeCurrency,
SuplrCustJournalAmount.TransactionCurrency AS TransactionCurrency,
SuplrCustJournalAmount.BusinessPlace AS BusinessPlace,
case when PH_BSET_GLO.CountryCurrency is null then SuplrCustJournalAmount.CompanyCodeCurrency else PH_BSET_GLO.CountryCurrency end as CountryCurrency AS CountryCurrencyendasCountryCurrency
FROM P_PH_SuplrCustJournalAmount
LEFT OUTER JOIN I_Supplier AS Supplier ON /* join condition not captured in parsed metadata */
LEFT OUTER JOIN I_Customer AS Customer ON /* join condition not captured in parsed metadata */
LEFT OUTER JOIN I_AccountingDocument AS AccountingDocument ON /* join condition not captured in parsed metadata */
LEFT OUTER JOIN P_PH_SuplrCustJrnlTaxAmount AS PH_BSET_GLO ON /* join condition not captured in parsed metadata */
LEFT OUTER JOIN P_PH_JrnlWhldgTaxAmount AS WhldgTaxItem ON /* join condition not captured in parsed metadata */
;