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_PH_SalesPurchasesSummaryItem.
-- 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: PPHSLSP
-- Parameters: P_CompanyCode : fis_bukrs
CREATE VIEW P_PH_SalesPurchasesSummaryItem AS
SELECT
TaxItem.CompanyCode AS CompanyCode,
TaxItem.AccountingDocument AS AccountingDocument,
TaxItem.FiscalYear AS FiscalYear,
TaxItem.StatryRptgEntity AS StatryRptgEntity,
TaxItem.StatryRptCategory AS StatryRptCategory,
TaxItem.StatryRptRunID AS StatryRptRunID,
TaxItem.TaxItem AS TaxItem,
TaxItem.TaxItemGroupingVersion AS TaxItemGroupingVersion,
TaxItem.TransactionTypeDetermination AS TransactionTypeDetermination,
TaxItem.TaxCode AS TaxCode,
TaxItem.TaxBox AS TaxBox,
TaxItem.ValidFrom AS ValidFrom,
TaxItem.TaxBoxStructureType AS TaxBoxStructureType,
TaxItem.TaxGroup AS TaxGroup,
TaxItem.FiscalPeriod AS FiscalPeriod,
TaxItem.PostingDate AS PostingDate,
TaxItem.ReportingDate AS ReportingDate,
TaxItem.DocumentDate AS DocumentDate,
_CalendarDate.LastDayOfMonthDate AS LastDayOfMonthDate,
TaxItem.TaxRate AS TaxRate,
TaxItem.TaxType AS TaxType,
FiscalYearPeriodForCmpnyCode.FiscalPeriodEndDate AS FiscalPeriodEndDate,
TaxItem.GLAccount AS GLAccount,
BusinessPlace,
case when _CustomerSupplierLineItem.Customer <> '' then _CustomerSupplierLineItem.Customer when _CustomerSupplierLineItem.Supplier <> '' then _CustomerSupplierLineItem.Supplier end as BusinessPartner AS SupplierendasBusinessPartner,
case when _CustomerSupplierLineItem.Customer <> '' then case when _OneTimeAccountBP.TaxID3 <> '' or _CustomerSupplierLineItem._Customer.TaxNumber3 <> '' then coalesce(_OneTimeAccountBP.TaxID3 ,_CustomerSupplierLineItem._Customer.TaxNumber3) else coalesce(_OneTimeAccountBP.TaxID1 ,_CustomerSupplierLineItem._Customer.TaxNumber1) end when _CustomerSupplierLineItem.Supplier <> '' then case when _OneTimeAccountBP.TaxID3 <> '' or _CustomerSupplierLineItem._Supplier.TaxNumber3 <> '' then coalesce(_OneTimeAccountBP.TaxID3, _CustomerSupplierLineItem._Supplier.TaxNumber3) else coalesce(_OneTimeAccountBP.TaxID1, _CustomerSupplierLineItem._Supplier.TaxNumber1) end end as VATRegistration AS TaxNumber1endendasVATRegistration,
case when _CustomerSupplierLineItem.Customer <> '' then coalesce(_OneTimeAccountBP.Country, _CustomerSupplierLineItem._Customer.Country) when _CustomerSupplierLineItem.Supplier <> '' then coalesce(_OneTimeAccountBP.Country, _CustomerSupplierLineItem._Supplier.Country) end as BusinessPartnerCountry AS CountryendasBusinessPartnerCountry,
case when _CustomerSupplierLineItem.Customer <> '' then coalesce(_OneTimeAccountBP.BusinessPartnerName1 ,_CustomerSupplierLineItem._Customer._CustomerToBusinessPartner._BusinessPartner.FirstName) when _CustomerSupplierLineItem.Supplier <> '' then coalesce(_OneTimeAccountBP.BusinessPartnerName1 ,_CustomerSupplierLineItem._Supplier._SupplierToBusinessPartner._BusinessPartner.FirstName) end as FirstName AS FirstNameendasFirstName,
case when _CustomerSupplierLineItem.Customer <> '' then coalesce(_OneTimeAccountBP.BusinessPartnerName2 ,_CustomerSupplierLineItem._Customer._CustomerToBusinessPartner._BusinessPartner.MiddleName) when _CustomerSupplierLineItem.Supplier <> '' then coalesce(_OneTimeAccountBP.BusinessPartnerName2 ,_CustomerSupplierLineItem._Supplier._SupplierToBusinessPartner._BusinessPartner.MiddleName) end as MiddleName AS MiddleNameendasMiddleName,
case when _CustomerSupplierLineItem.Customer <> '' then coalesce(_OneTimeAccountBP.BusinessPartnerName3 ,_CustomerSupplierLineItem._Customer._CustomerToBusinessPartner._BusinessPartner.LastName) when _CustomerSupplierLineItem.Supplier <> '' then coalesce(_OneTimeAccountBP.BusinessPartnerName3 ,_CustomerSupplierLineItem._Supplier._SupplierToBusinessPartner._BusinessPartner.LastName) end as LastName AS LastNameendasLastName,
TaxItem.TaxAmountInRptgCrcy AS TaxAmountInCoCodeCrcy,
AmountInReportingCurrency,
TaxItem.ReportingCurrency AS currency,
substring(FiscalYearPeriodForCmpnyCode.FiscalYearEndDate,5,2) AS EndDateMonth
FROM I_StRpTaxItemLog AS TaxItem
LEFT OUTER JOIN I_FiscalYearPeriodForCmpnyCode AS FiscalYearPeriodForCmpnyCode ON /* join condition not captured in parsed metadata */
LEFT OUTER JOIN I_CalendarDate AS _CalendarDate ON PostingDate = _CalendarDate.CalendarDate -- association [0..1]
LEFT OUTER JOIN I_Customer_to_BusinessPartner AS _CustomerToBusinessPartner ON BusinessPartner = _CustomerToBusinessPartner.Customer -- association [0..1]
LEFT OUTER JOIN I_Supplier_to_BusinessPartner AS _SupplierToBusinessPartner ON BusinessPartner = _SupplierToBusinessPartner.Supplier -- association [0..1]
LEFT OUTER JOIN I_JournalEntryItemOneTimeData AS _OneTimeAccountBP ON _OneTimeAccountBP.CompanyCode = TaxItem.CompanyCode AND AccountingDocument = _OneTimeAccountBP.AccountingDocument AND FiscalYear = _OneTimeAccountBP.FiscalYear -- association [0..*]
;