Wednesday, February 8, 2017

F4111 VS F0911 Reconciliation..

drop table #temp11
drop table #temp12
drop table #temp13

--select * from proddta.f4111 where ILDGL>117000
--select * from proddta.f0911 where GLDGJ>117000


select  ildoc,ildct,ILJELN,ILLITM, ilmcu,iltrdj,ilicu,ildgl, sum(iltrqt)iltrqt,sum(ilpaid)/100ilpaid into #temp11
from proddta.f4111 where ILDGL>117000
group by   ildoc,ildct,ILJELN,ILLITM, ilmcu,iltrdj,ilicu,ildgl


select  gldoc,gldct,GLJELN,glmcu,gLexr, glsub,glani,sum(glu)/100 glu, sum(glaa)/100 glaa into #temp12
from proddta.f0911 where gLDGj>117000 and gldct in(
select  distinct ildct from proddta.f4111 where ILDGL>117000)
group by   GLDOC,gldct,glexr,glsub,GLJELN,glani,glmcu


select *,( glaa-ilpaid) amt into #temp13
 from #temp11
left outer join #temp12 on ildoc=gldoc and ildct=gldct and GLJELN=iljeln
--where len(glsub) >3 and glaa-ilpaid<>0

select
ildoc DOC#,ildct DcTy,illitm ItemNo,ilmcu BP,iltrqt Inv_Qty,ilpaid Inv_Amt,glani Acno,ilicu BatchNo,
DATEADD(dy, cast(iltrdj as varchar(10)) % 1000, DATEADD(yy, cast(iltrdj as varchar(10)) / 1000,-1)) TransDate,
DATEADD(dy, cast(ildgl as varchar(10)) % 1000, DATEADD(yy, cast(ildgl as varchar(10)) / 1000,-1)) GL_Date,
glu GL_Qty,glaa GL_Amt, (ilpaid-glaa) AmtDiff,
case when (ilpaid-glaa)=0 then 'Recoincile' when glaa is null then  'Not in GL' else 'Not Recoinciled' end  RecoincileYN
from #temp13 order by 4,3,2
-- IK                   

No comments: