Код: Выделить всё
.create view vwSld as select * from saldmoun
where ((ch==scheto and sub==SUBOSSCH and strtodate(c0p2,'DD/MM/YYYY')<<=datesal and strtodate(c0p3,'DD/MM/YYYY')>>=datesal ))
;
.create view vwOD select * from oborot where ((
ch==scheto and sub==subossch and strtodate(c0p2,'DD/MM/YYYY')<<=datob and strtodate(c0p3,'DD/MM/YYYY')>>=datob));
.create view vwMain as select * from mtKau (i01);
.....
vwSld._loop saldmoun {
if getfirst fastfirstrow mtKau where ((saldmoun.KAUOS[1]==mtKAU.KAU))<>tsOk {
ClearBuffer(vwMain.tnmtKAU);
vwMain.mtKAU.Sch := vwSld.saldmoun.scheto;
vwMain.mtKAU.Sub := vwSld.saldmoun.SUBOSSCH;
vwMain.mtKAU.KAU := vwSld.saldmoun.KAUOS[1];
vwMain.mtKAU.Sum := vwSld.saldmoun.sums;
vwMain.insert current mtKAU;
} // if saldmoun.KAUOS[1]==mtKAU.name
else {
vwMain.Update current mtKAU set
mtKAU.Sum := mtKAU.Sum + vwSld.saldmoun.sums;
} //else
} //loop saldmoun
vwOD._loop oborot {
if getfirst mtKau where ((oborot.KAUOS[1]==mtKau.KAU))<>tsOk {
ClearBuffer(vwMain.tnmtKau);
vwMain.mtKau.Sch := vwOD.oborot.scheto;
vwMain.mtKau.Sub := vwOD.oborot.SUBOSSCH;
vwMain.mtKau.KAU := vwOD.oborot.KAUOS[1];
vwMain.mtKau.SumD := vwOD.oborot.sumob;
vwMain.insert current mtKau;
} // if oborot.KAUOS[1]==mtKau.name
else {
vwMain.Update current mtKau set
mtKau.SumD := mtKau.SumD + vwOD.oborot.sumob;
} //else
} //loop oborot