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_StRpWhldgTaxItem.
-- 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.
CREATE VIEW P_StRpWhldgTaxItem AS
SELECT
wht.CompanyCode AS CompanyCode,
wht.AccountingDocument AS AccountingDocument,
wht.FiscalYear AS FiscalYear,
wht.AccountingDocumentItem AS AccountingDocumentItem,
wht.WithholdingTaxType AS WithholdingTaxType,
wht.WithholdingTaxCode AS WithholdingTaxCode,
wht._WithholdingTaxCode.OfficialWhldgTaxCode AS OfficialWhldgTaxCode,
wht.Country AS Country,
doc.BusinessPlace AS BusinessPlace,
doc.BusinessArea AS BusinessArea,
wht.FinancialAccountType AS FinancialAccountType,
doc.Customer AS Debtor,
doc.Supplier AS Creditor,
doc._Customer.CustomerName AS CustomerName,
doc._Customer.BPCustomerName AS BPCustomerName,
case when doc.Customer = '' or doc.Customer is null then doc.Supplier else doc.Customer end as BusinessPartner AS CustomerendasBusinessPartner,
doc._JournalEntry.FiscalPeriod AS FiscalPeriod,
doc._JournalEntry.PostingDate AS PostingDate,
doc._JournalEntry.DocumentDate AS DocumentDate,
doc._JournalEntry.WithholdingTaxReportingDate AS WithholdingTaxReportingDate,
case when doc.SpecialGLTransactionType = 'W' then doc.DueCalculationBaseDate else doc._JournalEntry.PostingDate end as ReportingDate AS PostingDateendasReportingDate,
doc.ClearingDate AS ClearingDate,
doc.ClearingAccountingDocument AS ClearingAccountingDocument,
doc.ClearingJournalEntry AS ClearingJournalEntry,
doc.ClearingJournalEntryFiscalYear AS ClearingJournalEntryFiscalYear,
doc.PostingKey AS PostingKey,
doc._JournalEntry.AccountingDocumentType AS AccountingDocumentType,
doc.SpecialGLCode AS SpecialGLCode,
doc.SpecialGLTransactionType AS SpecialGLTransactionType,
doc.Reference3IDByBusinessPartner AS Reference3IDByBusinessPartner,
doc.InvoiceReference AS InvoiceReference,
doc.InvoiceReferenceFiscalYear AS InvoiceReferenceFiscalYear,
doc.InvoiceItemReference AS InvoiceItemReference,
doc.TaxSection AS TaxSection,
doc._JournalEntry.IsReversed AS IsReversed,
doc._JournalEntry.IsReversal AS IsReversal,
doc._JournalEntry.ReverseDocument AS ReverseDocument,
doc.DebitCreditCode AS DebitCreditCode,
doc.ClearingItem AS ClearingItem,
doc._JournalEntry.ExchangeRateType AS ExchangeRateType,
doc.CompanyCodeCurrency AS ReportingCurrency,
doc.TransactionCurrency AS TransactionCurrency,
doc.AdditionalCurrency1 AS AdditionalCurrency1,
doc.AdditionalCurrency2 AS AdditionalCurrency2,
doc.AmountInCompanyCodeCurrency AS AmountInCompanyCodeCurrency,
doc.AmountInTransactionCurrency AS AmountInTransactionCurrency,
doc.AmountInAdditionalCurrency1 AS AmountInAdditionalCurrency1,
doc.AmountInAdditionalCurrency2 AS AmountInAdditionalCurrency2,
doc.TaxAmountInCoCodeCrcy AS TaxAmountInCoCodeCrcy,
doc.TaxAmount AS TaxAmount,
doc.TaxAmountInAdditionalCurrency1 AS TaxAmountInAdditionalCurrency1,
doc.TaxAmountInAdditionalCurrency2 AS TaxAmountInAdditionalCurrency2,
wht.WhldgTaxBaseIsEnteredManually AS WhldgTaxBaseIsEnteredManually,
wht.WhldgTaxIsEnteredManually AS WhldgTaxIsEnteredManually,
wht.WhldgTaxItemStatus AS WhldgTaxItemStatus,
doc.WithholdingTaxBaseAmount AS AggrgdWhldgTxBaseAmtInCCCrcy,
doc.WithholdingTaxAmount AS AggrgdWhldgTaxAmtInCCCrcy,
doc.CashDiscountAmtInCoCodeCrcy AS CashDiscountAmtInCoCodeCrcy,
wht.WhldgTaxExmptAmtInCoCodeCrcy AS WhldgTaxExmptAmtInCoCodeCrcy,
wht.WhldgTaxExmptAmtInTransacCrcy AS WhldgTaxExmptAmtInTransacCrcy,
wht.WhldgTaxExmptAmtInAddlCrcy2 AS WhldgTaxExmptAmtInAddlCrcy2,
wht.WhldgTaxExmptAmtInAddlCrcy3 AS WhldgTaxExmptAmtInAddlCrcy3,
wht.WhldgTaxBaseAmtInCoCodeCrcy - wht.WhldgTaxAmtInCoCodeCrcy AS WhldgTaxDeductedNetAmount,
wht.WhldgTaxBaseAmtInTransacCrcy - wht.WhldgTaxAmtInTransacCrcy AS WhldgTxDdctdNetAmtInTransCrcy,
wht.RptgWhldgTxBaseAmtInCoCodeCrcy AS RptgWhldgTxBaseAmtInCoCodeCrcy,
wht.WhldgTaxExmptCertificate AS WhldgTaxExmptCertificate,
wht.GLAccount AS GLAccount,
wht.SupplierRecipientType AS SupplierRecipientType,
wht.WithholdingTaxExmptPercent AS WithholdingTaxExmptPercent,
wht.WithholdingTaxPercent AS WithholdingTaxPercent,
wht.IsSelfWhldgTax AS IsSelfWhldgTax,
wht.IsGrossingUp AS IsGrossingUp,
wht.WithholdingTaxCertificate AS WithholdingTaxCertificate,
wht.WhldgTaxCertDate AS WhldgTaxCertDate,
wht._WithholdingTaxCode.WithholdingTaxIncomeType AS WithholdingTaxIncomeType,
wht.IN_ClrgWithholdingTaxDocument AS IN_ClrgWithholdingTaxDocument,
wht.IN_ClrgWithholdingTaxDate AS IN_ClrgWithholdingTaxDate,
wht.IN_ReferenceDocumentNumber AS IN_ReferenceDocumentNumber,
wht.DownPaymentIsCleared AS DownPaymentIsCleared,
wht.DocumentIsPartialExempted AS DocumentIsPartialExempted,
wht.IN_WhldgTaxRecordTypeTrans AS IN_WhldgTaxRecordTypeTrans,
case when doc.Customer = '' or doc.Customer is null then coalesce( concat_with_space(concat_with_space(_Onetime.BusinessPartnerName1, _Onetime.BusinessPartnerName2, 1), (concat_with_space(_Onetime.BusinessPartnerName3, _Onetime.BusinessPartnerName4, 1)), 1) ,doc._Supplier.SupplierName) else coalesce(concat_with_space(concat_with_space(_Onetime.BusinessPartnerName1, _Onetime.BusinessPartnerName2, 1), (concat_with_space(_Onetime.BusinessPartnerName3, _Onetime.BusinessPartnerName4, 1)), 1) ,doc._Customer.CustomerName) end as Name AS CustomerNameendasName,
case when doc.Customer = '' or doc.Customer is null then coalesce( concat_with_space(concat_with_space(_Onetime.BusinessPartnerName1, _Onetime.BusinessPartnerName2, 1), (concat_with_space(_Onetime.BusinessPartnerName3, _Onetime.BusinessPartnerName4, 1)), 1) ,doc._Supplier.BPSupplierName) else coalesce(concat_with_space(concat_with_space(_Onetime.BusinessPartnerName1, _Onetime.BusinessPartnerName2, 1), (concat_with_space(_Onetime.BusinessPartnerName3, _Onetime.BusinessPartnerName4, 1)), 1) ,doc._Customer.BPCustomerName) end as BusinessPartnerName AS BPCustomerNameendasBusinessPartnerName,
case when doc.Customer = '' or doc.Customer is null then coalesce(_Onetime.TaxID1 ,doc._Supplier.TaxNumber1) else coalesce(_Onetime.TaxID1,doc._Customer.TaxNumber1) end as TaxNumber1 AS TaxNumber1endasTaxNumber1,
case when doc.Customer = '' or doc.Customer is null then coalesce(_Onetime.TaxID2,doc._Supplier.TaxNumber2) else coalesce(_Onetime.TaxID2,doc._Customer.TaxNumber2) end as TaxNumber2 AS TaxNumber2endasTaxNumber2,
case when doc.Customer = '' or doc.Customer is null then coalesce(_Onetime.TaxID3,doc._Supplier.TaxNumber3) else coalesce(_Onetime.TaxID3,doc._Customer.TaxNumber3) end as TaxNumber3 AS TaxNumber3endasTaxNumber3,
case when doc.Customer = '' or doc.Customer is null then coalesce(_Onetime.TaxID4,doc._Supplier.TaxNumber4) else coalesce(_Onetime.TaxID4,doc._Customer.TaxNumber4) end as TaxNumber4 AS TaxNumber4endasTaxNumber4,
case when doc.Customer = '' or doc.Customer is null then coalesce(_Onetime.TaxID5,doc._Supplier.TaxNumber5) else coalesce(_Onetime.TaxID5,doc._Customer.TaxNumber5) end as TaxNumber5 AS TaxNumber5endasTaxNumber5,
case when doc.Customer = '' or doc.Customer is null then (doc._Supplier.VATRegistration) else (doc._Customer.VATRegistration) end as VATRegistration AS VATRegistrationendasVATRegistration,
case when doc.Customer = '' or doc.Customer is null then coalesce(_Onetime.PostalCode,doc._Supplier._StandardAddress.PostalCode) else coalesce(_Onetime.PostalCode,doc._Customer._StandardAddress.PostalCode) end as PostalCode AS PostalCodeendasPostalCode,
case when doc.Customer = '' or doc.Customer is null then coalesce(_Onetime.CityName,doc._Supplier._StandardAddress.CityName) else coalesce(_Onetime.CityName,doc._Customer._StandardAddress.CityName) end as CityName AS CityNameendasCityName,
case when doc.Customer = '' or doc.Customer is null then coalesce(_Onetime.StreetAddressName,doc._Supplier._StandardAddress.StreetName) else coalesce(_Onetime.StreetAddressName,doc._Customer._StandardAddress.StreetName) end as StreetName AS StreetNameendasStreetName,
case when doc.Customer = '' or doc.Customer is null then doc._Supplier._StandardAddress.HouseNumber else doc._Customer._StandardAddress.HouseNumber end as HouseNumber AS HouseNumberendasHouseNumber,
case when doc.Customer = '' or doc.Customer is null then coalesce(_Onetime.BusinessPartnerName1,doc._Supplier._SupplierToBusinessPartner._BusinessPartner.SearchTerm1) else coalesce(_Onetime.BusinessPartnerName1,doc._Customer._CustomerToBusinessPartner._BusinessPartner.SearchTerm1) end as SearchTerm1 AS SearchTerm1endasSearchTerm1,
case when doc.Customer = '' or doc.Customer is null then coalesce(_Onetime.POBoxPostalCode,doc._Supplier._StandardAddress.POBoxPostalCode) else coalesce(_Onetime.POBoxPostalCode,doc._Customer._StandardAddress.POBoxPostalCode) end as POBoxPostalCode AS POBoxPostalCodeendasPOBoxPostalCode,
case when doc.Customer = '' or doc.Customer is null then coalesce(_Onetime.POBox,doc._Supplier._StandardAddress.POBox) else coalesce(_Onetime.POBox,doc._Customer._StandardAddress.POBox) end as POBox AS POBoxendasPOBox,
case when doc.Customer = '' or doc.Customer is null then coalesce(_Onetime.Region,doc._Supplier._StandardAddress.Region) else coalesce(_Onetime.Region,doc._Customer._StandardAddress.Region) end as Region AS RegionendasRegion,
case when doc.Customer = '' or doc.Customer is null then coalesce(_Onetime.Country,doc._Supplier._StandardAddress.Country) else coalesce(_Onetime.Country,doc._Customer._StandardAddress.Country) end as BusinessPartnerCountry AS CountryendasBusinessPartnerCountry,
cast(coalesce(coalesce(_Onetime.TaxNumberType, doc._Customer.TaxNumberType),doc._Supplier.TaxNumberType) as stcd_typ preserving type ) AS TaxNumberType,
case when doc.Customer = '' or doc.Customer is null then doc._Supplier.SupplierLanguage else doc._Customer.Language end as Language AS LanguageendasLanguage,
wht._AccountingDocument.DocumentReferenceID AS DocumentReferenceID,
wht._AccountingDocument.TransactionCode AS TransactionCode,
wht._AccountingDocument.AccountingDocumentHeaderText AS AccountingDocumentHeaderText,
doc.DocumentItemText AS DocumentItemText,
doc._Supplier.IsNaturalPerson AS IsNaturalPerson,
doc._Supplier._StandardAddress._DefaultEmailAddress.EmailAddress AS EmailAddress,
_TaxType.wt_tpnr AS SqntlNmbrOfWhldgTaxType,
_TaxType.wt_wtdp AS DependencyNmbrOfWhldgTaxType,
_TaxType.wt_inheritbase AS WhldgTaxBaseIsInherited,
doc._JournalEntry.SenderCompanyCode AS SenderCompanyCode,
doc._JournalEntry.SenderAccountingDocument AS SenderAccountingDocument,
doc._JournalEntry.SenderFiscalYear AS SenderFiscalYear,
doc._JournalEntry.SenderLogicalSystem AS SenderLogicalSystem,
wht._WithholdingTaxCode AS _WithholdingTaxCode,
wht._CompanyCode AS _CompanyCode,
doc._Supplier AS _Supplier,
doc._Customer AS _Customer,
doc AS _OperationalAcctgDocItem
FROM I_Withholdingtaxitem AS wht
LEFT OUTER JOIN I_OperationalAcctgDocItem AS doc ON wht.CompanyCode = doc.CompanyCode AND wht.AccountingDocument = doc.AccountingDocument AND wht.FiscalYear = doc.FiscalYear AND wht.AccountingDocumentItem = doc.AccountingDocumentItem AND doc.WithholdingTaxCode <> '' -- association [0..1]
LEFT OUTER JOIN I_JournalEntryItemOneTimeData AS _Onetime ON wht.CompanyCode = _Onetime.CompanyCode AND wht.AccountingDocument = _Onetime.AccountingDocument AND wht.FiscalYear = _Onetime.FiscalYear AND wht.AccountingDocumentItem = _Onetime.AccountingDocumentItem -- association [0..1]
LEFT OUTER JOIN I_Branch AS _Branch ON CompanyCode = _Branch.CompanyCode AND businessplace = _Branch.Branch -- association [0..1]
LEFT OUTER JOIN P_Withholdingtxtype AS _TaxType ON _TaxType.land1 = wht.Country AND _TaxType.witht = wht.WithholdingTaxType -- association [0..1]
LEFT OUTER JOIN I_Currency AS _ReportingCurrency ON ReportingCurrency = _ReportingCurrency.Currency -- association [0..1]
LEFT OUTER JOIN I_JournalEntry AS _JournalEntry ON CompanyCode = _JournalEntry.CompanyCode AND FiscalYear = _JournalEntry.FiscalYear AND AccountingDocument = _JournalEntry.AccountingDocument -- association [0..1]
;