有点象先进先出
回复 6 楼 tlliqi
是我思路的问题,或者说我没把真实的使用情况说出来,确实不好理解,sdta大哥帮我重新梳理了我的逻辑
T1=Seconds() Select A.Matnr,A.Werks,A.Lgort,A.Total,B.Menge,B.Budat,0000000000.00 库存数量 From Total A ; Left Join Daytime B On Alltrim(B.Matnr)==Alltrim(A.Matnr) And Alltrim(B.Werks)==Alltrim(A.Werks) ; And Alltrim(B.Lgort)==Alltrim(A.Lgort) Order By A.Matnr,A.Werks,A.Lgort,B.Budat Into Cursor Temp1 ReadWrite Replace All 库存数量 With Menge Select Matnr,Werks,Lgort,Total,Sum(Menge) Kczs From Temp1 Group By Matnr,Werks,Lgort,Total Into Cursor Temp2 nRc=0 && 入库数量与库存数量之差 Scan nRc=Temp2.Kczs-Temp2.Total Select Temp1 Scan For Alltrim(Temp1.Matnr)==Alltrim(Temp2.Matnr) And Alltrim(Temp1.Werks)==Alltrim(Temp2.Werks) And Alltrim(Temp1.Lgort)==Alltrim(Temp2.Lgort) nRc=nRc-Menge If nRc>0 Replace 库存数量 With 0 Else Replace 库存数量 With Abs(nRc) Exit EndIf EndScan EndScan MessageBox("共运行:"+Transform(Seconds()-T1)+" 秒") Select Temp1 Browse * 最后库存结果 Select * From Temp1 Where Not Empty(库存数量)