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_TH_StRpTaxReturn2.
-- 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_RelevantAmountPosition : relevantamountposition, P_StatryRptgEntity : srf_reporting_entity, P_StatryRptCategory : srf_rep_cat_id, P_StatryRptRunID : srf_report_run_id, P_ReportingCountry : land1
CREATE VIEW P_TH_StRpTaxReturn2 AS
SELECT
P_TH_StRpAverageTaxReturn.CompanyCode AS CompanyCode,
P_TH_StRpAverageTaxReturn.AccountingDocument AS AccountingDocument,
P_TH_StRpAverageTaxReturn.FiscalYear AS FiscalYear,
P_TH_StRpAverageTaxReturn.TaxItem AS TaxItem,
P_TH_StRpAverageTaxReturn.TaxCode AS TaxCode,
P_TH_StRpAverageTaxReturn.TransactionTypeDetermination AS TransactionTypeDetermination,
P_TH_StRpAverageTaxReturn.TaxBox AS TaxBox,
P_TH_StRpAverageTaxReturn.TaxDeclnAmountType AS TaxDeclnAmountType,
P_TH_StRpAverageTaxReturn.TaxItemGroupingVersion AS TaxItemGroupingVersion,
P_TH_StRpAverageTaxReturn.TaxBoxStrucValidityStartDate AS TaxBoxStrucValidityStartDate,
P_TH_StRpAverageTaxReturn.TaxBoxStructureType AS TaxBoxStructureType,
P_TH_StRpAverageTaxReturn.TaxGroup AS TaxGroup,
P_TH_StRpAverageTaxReturn.TaxBoxStructure AS TaxBoxStructure,
P_TH_StRpAverageTaxReturn.TaxBoxStrucValidityEndDate AS TaxBoxStrucValidityEndDate,
I_OperationalAcctgDocItem.BranchCode AS BranchCode,
P_TH_StRpAverageTaxReturn.SalesDocument AS SalesDocument,
P_TH_StRpAverageTaxReturn.BillingDocument AS BillingDocument,
I_StRpBPTaxItem.Customer AS Customer,
I_StRpBPTaxItem.Supplier AS Supplier,
P_TH_StRpAverageTaxReturn.ReportingDate AS ReportingDate,
P_TH_StRpAverageTaxReturn.PostingDate AS PostingDate,
P_TH_StRpAverageTaxReturn.DocumentDate AS DocumentDate,
P_TH_StRpAverageTaxReturn.TaxReportingDate AS TaxReportingDate,
P_TH_StRpAverageTaxReturn.FiscalPeriod AS FiscalPeriod,
P_TH_StRpAverageTaxReturn.IsReversal AS IsReversal,
P_TH_StRpAverageTaxReturn.IsReversed AS IsReversed,
P_TH_StRpAverageTaxReturn.AccountingDocumentType AS AccountingDocumentType,
P_TH_StRpAverageTaxReturn.TaxCalculationProcedure AS TaxCalculationProcedure,
P_TH_StRpAverageTaxReturn.DocumentReferenceID AS DocumentReferenceID,
P_TH_StRpAverageTaxReturn.CompanyCodeCountry AS CompanyCodeCountry,
P_TH_StRpAverageTaxReturn.ReportingCountry AS ReportingCountry,
P_TH_StRpAverageTaxReturn.TaxReturnCountry AS TaxReturnCountry,
P_TH_StRpAverageTaxReturn.ExchangeRate AS ExchangeRate,
P_TH_StRpAverageTaxReturn.TaxRate AS TaxRate,
P_TH_StRpAverageTaxReturn.TaxRateValidityStartDate AS TaxRateValidityStartDate,
P_TH_StRpAverageTaxReturn.GLAccount AS GLAccount,
P_TH_StRpAverageTaxReturn.BusinessPlace AS BusinessPlace,
P_TH_StRpAverageTaxReturn.TaxJurisdiction AS TaxJurisdiction,
P_TH_StRpAverageTaxReturn.AlternativeReferenceDocument AS AlternativeReferenceDocument,
P_TH_StRpAverageTaxReturn.LowestLevelTaxJurisdiction AS LowestLevelTaxJurisdiction,
_SDDocumentPartner.Customer AS BillToParty,
case when I_StRpBPTaxItem.Customer <> '' then coalesce(coalesce(I_StRpBPTaxItem._OneTimeDefTaxAccountBP.TaxID1, I_StRpBPTaxItem._OneTimeAccountBP.TaxID1), I_StRpBPTaxItem._Customer.TaxNumber1) when I_StRpBPTaxItem.Supplier <> '' then coalesce(coalesce(I_StRpBPTaxItem._OneTimeDefTaxAccountBP.TaxID1, I_StRpBPTaxItem._OneTimeAccountBP.TaxID1), I_StRpBPTaxItem._Supplier.TaxNumber1) end as TaxNumber1 AS TaxNumber1endasTaxNumber1,
I_StRpBPTaxItem._BusinessPartner.BusinessPartnerCategory AS BusinessPartnerCategory,
case when I_StRpBPTaxItem.Customer <> '' then coalesce(coalesce(I_StRpBPTaxItem._OneTimeDefTaxAccountBP.TaxID2, I_StRpBPTaxItem._OneTimeAccountBP.TaxID2), I_StRpBPTaxItem._Customer.TaxNumber2) when I_StRpBPTaxItem.Supplier <> '' then coalesce(coalesce(I_StRpBPTaxItem._OneTimeDefTaxAccountBP.TaxID2, I_StRpBPTaxItem._OneTimeAccountBP.TaxID2), I_StRpBPTaxItem._Supplier.TaxNumber2) end as TaxNumber2 AS TaxNumber2endasTaxNumber2,
case when I_StRpBPTaxItem.Customer <> '' then coalesce(coalesce(I_StRpBPTaxItem._OneTimeDefTaxAccountBP.TaxID3, I_StRpBPTaxItem._OneTimeAccountBP.TaxID3), I_StRpBPTaxItem._Customer.TaxNumber3) when I_StRpBPTaxItem.Supplier <> '' then coalesce(coalesce(I_StRpBPTaxItem._OneTimeDefTaxAccountBP.TaxID3, I_StRpBPTaxItem._OneTimeAccountBP.TaxID3), I_StRpBPTaxItem._Supplier.TaxNumber3) end as TaxNumber3 AS TaxNumber3endasTaxNumber3,
case when I_StRpBPTaxItem.Customer <> '' then I_StRpBPTaxItem.Customer when I_StRpBPTaxItem.Supplier <> '' then I_StRpBPTaxItem.Supplier end as BusinessPartner AS SupplierendasBusinessPartner,
case when I_StRpBPTaxItem.Customer <> '' and I_StRpBPTaxItem._OneTimeDefTaxAccountBP.AccountingDocument is null and I_StRpBPTaxItem._OneTimeAccountBP.AccountingDocument is null then I_StRpBPTaxItem._Customer.AddressID when I_StRpBPTaxItem.Supplier <> '' and I_StRpBPTaxItem._OneTimeDefTaxAccountBP.AccountingDocument is null and I_StRpBPTaxItem._OneTimeAccountBP.AccountingDocument is null then I_StRpBPTaxItem._Supplier.AddressID end as BusinessPartnerAddressID AS AddressIDendasBusinessPartnerAddressID,
case when I_StRpBPTaxItem.Customer <> '' then coalesce(coalesce(I_StRpBPTaxItem._OneTimeDefTaxAccountBP.Country, I_StRpBPTaxItem._OneTimeAccountBP.Country), I_StRpBPTaxItem._Customer.Country) when I_StRpBPTaxItem.Supplier <> '' then coalesce(coalesce(I_StRpBPTaxItem._OneTimeDefTaxAccountBP.Country, I_StRpBPTaxItem._OneTimeAccountBP.Country), I_StRpBPTaxItem._Supplier.Country) end as BusinessPartnerCountry AS CountryendasBusinessPartnerCountry,
case when I_StRpBPTaxItem.Customer <> '' then I_StRpBPTaxItem._Customer.CustomerName when I_StRpBPTaxItem.Supplier <> '' then I_StRpBPTaxItem._Supplier.SupplierName end as BusinessPartnerName AS SupplierNameendasBusinessPartnerName,
P_TH_StRpAverageTaxReturn.TaxType AS TaxType,
P_TH_StRpAverageTaxReturn.CompanyCodeCurrency AS CompanyCodeCurrency,
P_TH_StRpAverageTaxReturn.CountryCurrency AS CountryCurrency,
P_TH_StRpAverageTaxReturn.DocumentCurrency AS DocumentCurrency,
P_TH_StRpAverageTaxReturn.ReportingCurrency AS ReportingCurrency,
P_TH_StRpAverageTaxReturn.AdditionalCurrency1 AS AdditionalCurrency1,
P_TH_StRpAverageTaxReturn.AdditionalCurrency2 AS AdditionalCurrency2,
cast ( P_TH_StRpAverageTaxReturn.AmountInReportingCurrency as glo_amount_rptg_crcy ) AS AmountInReportingCurrency,
P_TH_StRpAverageTaxReturn.AmountInTransactionCurrency AS AmountInTransactionCurrency,
P_TH_StRpAverageTaxReturn.TaxBaseAmountInCoCodeCrcy AS TaxBaseAmountInCoCodeCrcy,
P_TH_StRpAverageTaxReturn.TaxAmountInCoCodeCrcy AS TaxAmountInCoCodeCrcy,
P_TH_StRpAverageTaxReturn.TaxBaseAmountInTransCrcy AS TaxBaseAmountInTransCrcy,
P_TH_StRpAverageTaxReturn.TaxAmount AS TaxAmount,
P_TH_StRpAverageTaxReturn.TaxBaseAmountInRptgCrcy AS TaxBaseAmountInRptgCrcy,
P_TH_StRpAverageTaxReturn.TaxAmountInRptgCrcy AS TaxAmountInRptgCrcy,
P_TH_StRpAverageTaxReturn.AmountInAdditionalCurrency1 AS AmountInAdditionalCurrency1,
P_TH_StRpAverageTaxReturn.AmountInAdditionalCurrency2 AS AmountInAdditionalCurrency2,
P_TH_StRpAverageTaxReturn.TaxBaseAmtInAdditionalCrcy1 AS TaxBaseAmtInAdditionalCrcy1,
P_TH_StRpAverageTaxReturn.TaxBaseAmtInAdditionalCrcy2 AS TaxBaseAmtInAdditionalCrcy2,
P_TH_StRpAverageTaxReturn.TaxAmountInAdditionalCurrency1 AS TaxAmountInAdditionalCurrency1,
P_TH_StRpAverageTaxReturn.TaxAmountInAdditionalCurrency2 AS TaxAmountInAdditionalCurrency2,
P_TH_StRpAverageTaxReturn.TaxIsNotDeductible AS TaxIsNotDeductible,
P_TH_StRpAverageTaxReturn._AccountingDocument AS _AccountingDocument,
P_TH_StRpAverageTaxReturn._TaxJurisdiction AS _TaxJurisdiction,
P_TH_StRpAverageTaxReturn._ReceivablesPayablesItem AS _ReceivablesPayablesItem,
P_TH_StRpAverageTaxReturn._TaxTypeText AS _TaxTypeText,
P_TH_StRpAverageTaxReturn._TaxCodeText AS _TaxCodeText
;