Skip to Content
1
Former Member
Mar 04, 2009 at 05:04 AM

Query Help required to Connect JDT1 with OINV tables

1634 Views

Dear Experts,

I have the following query which gives me the customer ageing report. I want some addtional fields from the OINV table and the document numbering table like Document Series Name, AR Invoice document Number,AR invoice remarks, BP Projects Number ( filled in accounting tab in BP projects) and in the query in Reference 1 column its giving the Invoice Numbers as posted in the Journal but for manual Journal Entries it not giving the Journal Number which I also want to be shown in Ref 1 or a seperat field.

The Query is as under :

select OCRD.cardcode 'Supplier Code',OCRD.cardname 'Name',sysdeb 'Debit Amount',syscred 'Credit Amount',

case JDT1.transtype

when '13' then 'INV'

when '14' then 'AR CN'

when '24' then 'INCOMING'

else 'Other'

end 'Type',

Ref1,

fccurrency 'BP Currency',

CONVERT(VARCHAR(10), refdate, 103)'Posting Date' ,

CONVERT(VARCHAR(10), duedate, 103) 'Due Date',

CONVERT(VARCHAR(10), taxdate, 103) 'Doc Date' ,

CASE

when (DATEDIFF(dd,refdate,current_timestamp))+1 < 31

then

case

when syscred <> 0 then syscred * - 1

else sysdeb

end

end "0-30 days",

case when ((datediff(dd,refdate,current_timestamp))+1 > 30

and (datediff(dd,refdate,current_timestamp))+1< 61)

then

case

when syscred <> 0 then syscred * - 1

else sysdeb

end

end "31 to 60 days",

case when ((datediff(dd,refdate,current_timestamp))+1 > 60

and (datediff(dd,refdate,current_timestamp))+1< 91)

then

case

when syscred <> 0 then syscred * - 1

else sysdeb

end

end "61 to 90 days",

CASE

when (DATEDIFF(dd,refdate,current_timestamp))+1 > 90

then

case

when syscred= 0 then sysdeb

when sysdeb= 0 then syscred * - 1

end

end "90 + days"

from JDT1,OCRD where JDT1.shortname = OCRD.cardcode and cardtype = 'c' and intrnmatch = '0'

ORDER BY OCRD.CARDCODE, taxdate

Would appreciate if you can help me to get a solution in it.

Regards,

Kamlesh