Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

SAP Business one Withholding Tax query

Hi Experts,

I have a challenge and i will need your help with a withholding tax query.

I want a withholding tax report query that involves, AP Invoice, Outgoing payment and AP Credit memo.

Urgent reply to this request will be appreciated.

Regards

Justice 

replied

USE [liner_12.08.15]

GO

/****** Object:  StoredProcedure [dbo].[WITHOLDING_new1]    Script Date: 08/14/2015 11:07:34 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER proc [dbo].[WITHOLDING_new1]

--declare

@docdate date,@docdate2 date

as

  --SET @DocDate='2015-07-01'

  --SET @DocDate2='2015-07-31'

begin

  IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[wtx29]') AND type in (N'U'))

select

ovpm.DocNum ,OVPM.CardCode,OVPM.CardName,vpm2.SumApplied as TaxbleAmnt ,

vpm2.WtAppld as WTSum,vpm2.WtAppldFC as WTSumFC,vpm2.U_DocNum as NumAtCard

,vpm2.AppliedFC as TxblAmntFC,ovpm.Comments ,ovpm.DocTotal,ovpm.DocDate

,ovpm.DocTotalFC,vpm2.InvoiceId ,vpm2.vatApplied ,vpm2.vatAppldFC ,pch5.TaxbleAmnt as NewTaxableAmt,pch5.WTAmnt as NewWtx,pch5.Rate,vpm2.DocRate

from VPM2 inner join ovpm on ovpm.DocEntry =vpm2.DocNum

inner join PCH5 on pch5.AbsEntry =vpm2.DocEntry

inner join OCRD on ocrd.CardCode =ovpm.CardCode

where

--ovpm.DocNum = '1863'

  OVPM.DocDate >= @docdate AND OVPM.DocDate <=@docdate2

  AND ovpm.Canceled <>'y' and VPM2.WtAppld <> 0.00

union

  SELECT T0.DocNum,T0.CardCode,T0.CardName,0 AS TaxbleAmnt,0 AS WTSum,0 AS WTSumFC,T0.NumAtCard ,0 AS TxblAmntFC

  ,T0.Comments,T0.DocTotal,t0.DocDate ,T0.DocTotalFC,0 AS InvoiceId ,0 as vatApplied, 0 as vatAppldFC ,0 as NewTaxableAmt,0 as NewWtx,0 as Rate,0 as DocRate

  FROM ORPC T0  INNER JOIN RPC1 T1 ON T0.[DocEntry] = T1.[DocEntry]

  INNER JOIN OCRD T2 ON T2.CardCode =T0.CardCode

  WHERE T0.DocType ='S' AND T1.AcctCode ='410095'

  and t0.CANCELED <> 'Y'and T0 .[DocDate] >=@docdate AND T0 .[DocDate]  <= @docdate2

end

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question