SELECT ltrim(jl.jobnumber) as jobnumber,jl.transnmbr,jl.mastertype,jl.masterid,pm.vendname,jl.debitamt,jl.crdtamnt,
VCHRNMBR = case isnull(pw.vchrnmbr,0) when 0 then case isnull(po.vchrnmbr,0) when 0 then ph.vchrnmbr else po.vchrnmbr end else pw.vchrnmbr end,
DOCTYPE = case isnull(pw.doctype,0) when 0 then case isnull(po.doctype,0) when 0 then ph.doctype else po.doctype end else pw.doctype end,
DOCDATE = case isnull(pw.docdate,0) when 0 then case isnull(po.docdate,0) when 0 then ph.docdate else po.docdate end else pw.docdate end,
POSTDATE = case isnull(pw.pstgdate,0) when 0 then case isnull(po.posteddt,0) when 0 then ph.posteddt else po.posteddt end else pw.pstgdate end,
--DOCNUMBR = case isnull(pw.docnumbr,0) when 0 then case isnull(po.docnumbr,0) when 0 then ph.docnumbr else po.docnumbr end else pw.docnumbr end,
DOCAMNT = case isnull(pw.docamnt,0) when 0 then case isnull(po.docamnt,0) when 0 then ph.docamnt else po.docamnt end else pw.docamnt end,
TRXDSCRN = case isnull(pw.trxdscrn,0) when 0 then case isnull(po.trxdscrn,0) when 0 then replace(ph.trxdscrn,CHAR(39),'') else replace(po.trxdscrn,CHAR(39),'') end else replace(pw.trxdscrn,CHAR(39),'') end,
jl.docsource,jl.actnumst,gl.accatnum
FROM gl00100 gl, gl00102 glc, pm00200 pm, job_linker as jl
LEFT OUTER JOIN pm10000 as pw
ON jl.transnmbr = pw.vchrnmbr
LEFT OUTER JOIN pm20000 as po
ON jl.transnmbr = po.vchrnmbr
LEFT OUTER JOIN pm30200 as ph
ON jl.transnmbr = ph.vchrnmbr
where jl.mastertype='VEN' and len(rtrim(jl.jobnumber))>0 and jl.masterid = pm.vendorid and gl.actnumbr_1=jl.actnumst and gl.accatnum=glc.accatnum and gl.accatnum>=31
order by jl.transnmbr
|