Skip to Content

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

Need selection criteria

Hii Experts,

I am new in this (sap) , I am having one query in which i need selection criteria as a business partner name .

this is query........

declare @fromdate as Datetime

Declare @Todate as Datetime

set @fromdate = ( select Min(ta.refdate) from OJDT ta where ta.refdate = [%0])

set @Todate = ( select Max(tb.refdate) from OJDT tb where tb.refdate = [%1])

SELECT DISTINCT T0.[RefDate], T0.[TransId],   T1.[ShortName]'GLAccount/BPCode', T2.[AcctName] 'GLName/BPName'

, T1.ContraAct'OffsetAccount',T1.[LineMemo]'Details',

(T1.[credit] - (isnull((select BcgSum from ORCT where TransId= T0.[TransId] AND CardCode= T1.[ShortName] ),0))) as 'Debit',

(-T1.[debit] - (isnull((select Bcgsum from OVPM where TransId = T0.[TransId] AND CardCode= T1.[ShortName]),0))) as 'Credit',

T3.[AcctName] AS 'Cash / Bank'

 

FROM OJDT T0 INNER JOIN JDT1 T1 ON  T0.[TransId] = T1.[TransId] INNER JOIN OACT T2 ON  T1.[Account] = T2.[AcctCode] INNER JOIN

oact t3 ON t3.AcctCode=t1.ContraAct

WHERE T0.[RefDate] BETWEEN @fromdate AND @todate  

ORDER BY T0.[RefDate]

Thank you in advance

Former Member
replied

HI Neelima,

Please try below query

Declare @fromdate as Datetime

Declare @Todate as Datetime

set @fromdate = ( select Min(ta.refdate) from OJDT ta where ta.refdate = [%0])

set @Todate = ( select Max(tb.refdate) from OJDT tb where tb.refdate = [%1])

SELECT DISTINCT T0.[RefDate], T0.[TransId],   T1.[ShortName]'GLAccount/BPCode', T2.[AcctName] 'GLName/BPName'

, T1.ContraAct'OffsetAccount',T1.[LineMemo]'Details',

(T1.[credit] - (isnull((select BcgSum from ORCT where TransId= T0.[TransId] AND CardCode= T1.[ShortName] ),0))) as 'Debit',

(-T1.[debit] - (isnull((select Bcgsum from OVPM where TransId = T0.[TransId] AND CardCode= T1.[ShortName]),0))) as 'Credit',

T3.[AcctName] AS 'Cash / Bank'

FROM OJDT

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

INNER JOIN OACT T2 ON  T1.[Account] = T2.[AcctCode]

INNER JOIN oact t3 ON t3.AcctCode=t1.ContraAct

Left Outer Join OCRD T4 on T1.shortName = T4.CardCode

WHERE T0.[RefDate] BETWEEN @fromdate AND @todate  and T4.CardName =N'[%2]'

ORDER BY T0.[RefDate]

Thanks

Unnikrishnan

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question