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_US_StRpFrgnVndrWhldgTxItm.
-- 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: IUSWHLDGTX1042S
CREATE VIEW I_US_StRpFrgnVndrWhldgTxItm AS
SELECT
WhldgTxItem.CompanyCode AS CompanyCode,
AccountingDocument,
FiscalYear,
AccountingDocumentItem,
WhldgTxItem.WithholdingTaxType AS WithholdingTaxType,
StatryRptgEntity,
StatryRptCategory,
StatryRptRunID,
WhldgTxItem.WithholdingTaxCode AS WithholdingTaxCode,
Country,
WhldgTxItem.BusinessPartner AS BusinessPartner,
PostingDate,
DocumentDate,
ReportingDate,
ClearingDate,
FinancialAccountType,
ReportingCurrency,
WhldgTaxBaseAmtInCoCodeCrcy,
WhldgTaxAmtInCoCodeCrcy,
cast( '' as ad_name1 ) AS PayerName1,
cast( '' as ad_name2 ) AS PayerName2,
cast( '' as ad_name3 ) AS PayerName3,
cast( '' as ad_city1 ) AS CityName,
cast( '' as regio ) AS Region,
cast( '' as ad_tlnmbr ) AS PhoneNumber,
cast( '' as ad_strspp1 ) AS StreetPrefixName,
cast( '' as ad_street ) AS StreetName,
cast( '' as ad_hsnm1 ) AS HouseNumber,
cast( '' as butxt ) AS CompanyCodeName,
cast( '' as ad_pstcd1 ) AS CompanyPostalCode,
cast ('' as ad_citynum ) AS CityCode,
cast( 'EN' as spras ) AS Language,
case when WhldgTxItem._Supplier.SupplierFullName is initial or WhldgTxItem._Supplier.SupplierFullName = '' then WhldgTxItem._Customer.CustomerFullName else WhldgTxItem._Supplier.SupplierFullName end as SupplierFullName AS SupplierFullNameendasSupplierFullName,
_CountryText.CountryName AS BusinessPartnerCountryName,
CustomerSupplierCityName,
CustomerSupplierStreetName,
OrganizationBPName1,
OrganizationBPName2,
BPStPrefixName,
BPRgn,
_RegionText.RegionName AS RegionName,
BusPartPOBoxRgn,
BusPartPOBoxDvtgCityName,
CustomerSupplierHouseNumber,
cast(coalesce(_OneTime.TaxID1, _BPTxNmbr1.BPTaxNumber) as stcd1) AS TaxNumber1,
cast(coalesce(_OneTime.TaxID2, _BPTxNmbr2.BPTaxNumber) as stcd2) AS TaxNumber2,
BPTxNmbr4.BPTaxNumber AS TaxNumber4,
BPTxNmbr5.BPTaxLongNumber AS TaxNumber5,
PayeePostalCode AS CustomerSupplierPostalCode,
BusPartPOBox,
WithholdingTaxCountry,
_WithholdingTaxCode.WhldgTaxReferenceText AS WhldgTaxReferenceText,
_WithholdingTaxCode.OfficialWhldgTaxCode AS OfficialWhldgTaxCode,
cast(case WhldgTxItem.BusinessPartnerCountry when 'US' then BPRgn else ' ' end as abap.char( 2 ) ) as US_TaxState AS char2asUS_TaxState,
cast( case when WhldgTxItem.Creditor is not initial or WhldgTxItem.Creditor <> '' then WhldgTxItem._Supplier.BirthDate else case when WhldgTxItem._Customer._CustomerToBusinessPartner._BusinessPartner.BusinessPartnerCategory = '1' then WhldgTxItem._Customer._CustomerToBusinessPartner._BusinessPartner.BirthDate else '' end end as datum) as BirthDate AS BirthDateelseendendasdatumasBirthDate,
cast( '' as abap.char( 3 )) AS PayerRegion,
cast( '' as abap.char( 3 )) AS PayerCountryName,
case when WhldgTxItem._CompanyCode.ExtendedWhldgTaxIsActive = 'X' and _WithholdingTaxCode.WhldgTaxReferenceText = 'CHP3' and ( _WithholdingTax.IsWithholdingTaxSubject = 'X' or _CustWithholdingTax.WithholdingTaxAgent = 'X' ) then coalesce(_WithholdingTax.RecipientType,_CustWithholdingTax.RecipientType) end as RecipientType AS RecipientTypeendasRecipientType,
case when WhldgTxItem._CompanyCode.ExtendedWhldgTaxIsActive = 'X' and _WithholdingTaxCode.WhldgTaxReferenceText = 'CHP3' and (_WithholdingTax.ExemptionReason <> '' or _CustWithholdingTax.ExemptionReason <> '') and WhldgTxItem.WhldgTaxExmptCertificate <> '' and (_WithholdingTax.IsWithholdingTaxSubject = 'X' or _CustWithholdingTax.WithholdingTaxAgent = 'X') then coalesce(_WithholdingTax.ExemptionReason,_CustWithholdingTax.ExemptionReason) when WhldgTxItem._CompanyCode.ExtendedWhldgTaxIsActive = 'X' and _WithholdingTaxCode.WhldgTaxReferenceText = 'CHP3' and (_WithholdingTax.ExemptionReason = '' or _CustWithholdingTax.ExemptionReason = '') and WhldgTxItem.WhldgTaxExmptCertificate = '' and (_WithholdingTax.IsWithholdingTaxSubject = 'X' or _CustWithholdingTax.WithholdingTaxAgent = 'X') then '' when WhldgTxItem._CompanyCode.ExtendedWhldgTaxIsActive = 'X' and _WithholdingTaxCode.WhldgTaxReferenceText = 'CHP4' then _WithholdingTaxChp.ExemptionReason end as ExemptionReason AS ExemptionReasonendasExemptionReason,
WhldgTaxAmtInCoCodeCrcy AS US_FederalTaxAmtInCoCodeCrcy,
_WithholdingTaxCode.WithholdingTaxPercent AS TaxRate,
US_RecipientForeignTaxID,
US_ForeignSuplrHasPartnership,
US_ForeignSuplrLmtnOnBnftCode,
US_Chapter4StatusCode,
WhldgTxItem.BusinessPartnerNumber AS BusinessPartnerNumber,
WhldgTxItem.SpecialGLCode AS SpecialGLCode
FROM P_US_StrpWhldgTaxItem AS WhldgTxItem
LEFT OUTER JOIN I_BusinessPartnerCustWhdgTax AS _CustWithholdingTax ON WhldgTxItem.CompanyCode = _CustWithholdingTax.CompanyCode AND WhldgTxItem.BusinessPartnerNumber = _CustWithholdingTax.BusinessPartner AND WhldgTxItem.Debtor = _CustWithholdingTax.Customer AND WhldgTxItem.WithholdingTaxType = _CustWithholdingTax.WithholdingTaxType -- association [0..1]
LEFT OUTER JOIN I_RegionText AS _RegionText ON _RegionText.Region = WhldgTxItem.BPRgn AND _RegionText.Country = WhldgTxItem.BusinessPartnerCountry AND _RegionText.Language = $session.system_language AND WhldgTxItem.BPRgn <> 'CA' -- association [0..1]
LEFT OUTER JOIN I_CountryText AS _CountryText ON _CountryText.Country = WhldgTxItem.BusinessPartnerCountry AND _CountryText.Language = $session.system_language -- association [0..1]
;