Skip to Content

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

Query for ourgoing payments on Account

Hi Experts,

I have the following query that I want to use to query outgoing payments for a CashBook I want to build. This is for Accounts only:

SELECT DISTINCT

T0.[RefDate], T1.[ContraAct], T0.[Ref2], T1.[Debit], T1.[Credit], T2.[Address], T3.Descrip AS 'Description'

FROM

OJDT T0 INNER JOIN

JDT1 T1 ON T0.[TransId] = T1.[TransId] INNER JOIN

OVPM T2 ON T0.[TransId] = T2.[TransId] INNER JOIN

VPM4 T3 ON T2.[DocEntry] = T3.[DocNum]

WHERE T0.RefDate BETWEEN '04-01-2015' AND '04-30-2015' AND T2.DocEntry=T3.DocNum

AND T2.CounterRef = '478' AND T2.DocType IN ('A')

When I run the above query, I get the following results:

It returns 8 rows for the following outgoing payment that has two lines:

How do I tweak the query above to return just the 2 rows as in the image above such that the result of the query is:

Any help appreciated.

Regards,

Kinyanjui.

Tags:
Former Member
replied

Hi,

Please try below Query

SELECT Distinct T0.[RefDate], T1.Account, T0.[Ref2], T1.[Debit], T1.[Credit], T2.[Address], T3.Descrip AS 'Description'

FROM

OJDT T0 INNER JOIN

JDT1 T1 ON T0.[TransId] = T1.[TransId]

INNER JOIN OVPM T2 ON T0.TransType =46 and   T0.[TransId] = T2.[TransId] and T1.Account <> T2.CashAcct

INNER JOIN VPM4 T3 ON T2.[DocEntry] = T3.[DocNum] and T1.Account = T3.AcctCode

WHERE T0.RefDate BETWEEN '01-04-2015' AND '10-07-2015' AND T2.DocEntry=T3.DocNum

AND T2.CounterRef = '478' AND T2.DocType IN ('A')

Thanks

Unnikrishnan

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