Пользовался, в таком варианте (в данном случае подошла таблица PARPRICE в качестве временной):
Код: Выделить всё
! отчет для замены элемента аналитики на другой в проводках, сальдо, шаблонах проводок ТХО
.form 'ARD101109'
.ARD
.Group 'Сервис ТНФ'
.nameinlist 'Замена элемента аналитики на другой в проводках, сальдо, ТХО'
.declare
#include getkau.vih
.enddeclare
.create view t1 from oborot,saldmoun,hozobor,PARPRICE(memory);
.var
iGetKau: GetKau; //объектный фейс для выбора аналитики по коду.
c1,c2:comp;
w1,w2:word;
n1:word
.endvar
.fields
n1
.endfields
.begin
message('Выберите каталог и ЗАМЕНЯЕМЫЙ элемент',ok);
if RunInterface('int100923',w1)=cmCancel then ARD101109.fExit
end.
.begin
c1:=0;
! 5 - одиночный режим выбора без редактирования каталога
iGetKau.GetCodeKau(5,w1,c1);
if c1=0 then ARD101109.fExit
end.
.begin
message('Выберите каталог и ЗАМЕНЯЮЩИЙ элемент',ok);
if RunInterface('int100923',w2)=cmCancel then ARD101109.fExit
end.
.begin
c2:=0;
iGetKau.GetCodeKau(5,w2,c2);
if c2=0 then ARD101109.fExit
end.
.begin
n1:=0;
! проводки по ДТ
t1.delete all PARPRICE;
! конструкция insert into t1 select 1,2,3 from t2 требует присвоения значений
! всему количеству полей таблицы t1 (1,2,3) значениями из таблицы t2 (или нулями)
insert into PARPRICE select 0,oborot.nrec,0 from oborot where((w1==oborot.TBLOS[1] and c1==oborot.KAUOS[1]));
t1._loop parprice{
update oborot where((PARPRICE.cPRICEs==oborot.nrec)) set oborot.TBLOS[1]:=w2,oborot.KAUOS[1]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,oborot.nrec,0 from oborot where((w1==oborot.TBLOS[2] and c1==oborot.KAUOS[2]));
t1._loop parprice{
update oborot where((PARPRICE.cPRICEs==oborot.nrec)) set oborot.TBLOS[2]:=w2,oborot.KAUOS[2]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,oborot.nrec,0 from oborot where((w1==oborot.TBLOS[3] and c1==oborot.KAUOS[3]));
t1._loop parprice{
update oborot where((PARPRICE.cPRICEs==oborot.nrec)) set oborot.TBLOS[3]:=w2,oborot.KAUOS[3]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,oborot.nrec,0 from oborot where((w1==oborot.TBLOS[4] and c1==oborot.KAUOS[4]));
t1._loop parprice{
update oborot where((PARPRICE.cPRICEs==oborot.nrec)) set oborot.TBLOS[4]:=w2,oborot.KAUOS[4]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,oborot.nrec,0 from oborot where((w1==oborot.TBLOS[5] and c1==oborot.KAUOS[5]));
t1._loop parprice{
update oborot where((PARPRICE.cPRICEs==oborot.nrec)) set oborot.TBLOS[5]:=w2,oborot.KAUOS[5]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,oborot.nrec,0 from oborot where((w1==oborot.TBLOS[6] and c1==oborot.KAUOS[6]));
t1._loop parprice{
update oborot where((PARPRICE.cPRICEs==oborot.nrec)) set oborot.TBLOS[6]:=w2,oborot.KAUOS[6]:=c2;
inc(n1)};
! проводки по КТ
t1.delete all PARPRICE;
insert into PARPRICE select 0,oborot.nrec,0 from oborot where((w1==oborot.TBLkS[1] and c1==oborot.KAUkS[1]));
t1._loop parprice{
update oborot where((PARPRICE.cPRICEs==oborot.nrec)) set oborot.TBLkS[1]:=w2,oborot.KAUkS[1]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,oborot.nrec,0 from oborot where((w1==oborot.TBLkS[2] and c1==oborot.KAUkS[2]));
t1._loop parprice{
update oborot where((PARPRICE.cPRICEs==oborot.nrec)) set oborot.TBLkS[2]:=w2,oborot.KAUkS[2]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,oborot.nrec,0 from oborot where((w1==oborot.TBLkS[3] and c1==oborot.KAUkS[3]));
t1._loop parprice{
update oborot where((PARPRICE.cPRICEs==oborot.nrec)) set oborot.TBLkS[3]:=w2,oborot.KAUkS[3]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,oborot.nrec,0 from oborot where((w1==oborot.TBLkS[4] and c1==oborot.KAUkS[4]));
t1._loop parprice{
update oborot where((PARPRICE.cPRICEs==oborot.nrec)) set oborot.TBLkS[4]:=w2,oborot.KAUkS[4]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,oborot.nrec,0 from oborot where((w1==oborot.TBLkS[5] and c1==oborot.KAUkS[5]));
t1._loop parprice{
update oborot where((PARPRICE.cPRICEs==oborot.nrec)) set oborot.TBLkS[5]:=w2,oborot.KAUkS[5]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,oborot.nrec,0 from oborot where((w1==oborot.TBLkS[6] and c1==oborot.KAUkS[6]));
t1._loop parprice{
update oborot where((PARPRICE.cPRICEs==oborot.nrec)) set oborot.TBLkS[6]:=w2,oborot.KAUkS[6]:=c2;
inc(n1)};
! Сальдо
t1.delete all PARPRICE;
insert into PARPRICE select 0,saldmoun.nrec,0 from saldmoun where((w1==saldmoun.TBLOS[1] and c1==saldmoun.KAUOS[1]));
t1._loop parprice{
update saldmoun where((PARPRICE.cPRICEs==saldmoun.nrec)) set saldmoun.TBLOS[1]:=w2,saldmoun.KAUOS[1]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,saldmoun.nrec,0 from saldmoun where((w1==saldmoun.TBLOS[2] and c1==saldmoun.KAUOS[2]));
t1._loop parprice{
update saldmoun where((PARPRICE.cPRICEs==saldmoun.nrec)) set saldmoun.TBLOS[2]:=w2,saldmoun.KAUOS[2]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,saldmoun.nrec,0 from saldmoun where((w1==saldmoun.TBLOS[3] and c1==saldmoun.KAUOS[3]));
t1._loop parprice{
update saldmoun where((PARPRICE.cPRICEs==saldmoun.nrec)) set saldmoun.TBLOS[3]:=w2,saldmoun.KAUOS[3]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,saldmoun.nrec,0 from saldmoun where((w1==saldmoun.TBLOS[4] and c1==saldmoun.KAUOS[4]));
t1._loop parprice{
update saldmoun where((PARPRICE.cPRICEs==saldmoun.nrec)) set saldmoun.TBLOS[4]:=w2,saldmoun.KAUOS[4]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,saldmoun.nrec,0 from saldmoun where((w1==saldmoun.TBLOS[5] and c1==saldmoun.KAUOS[5]));
t1._loop parprice{
update saldmoun where((PARPRICE.cPRICEs==saldmoun.nrec)) set saldmoun.TBLOS[5]:=w2,saldmoun.KAUOS[5]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,saldmoun.nrec,0 from saldmoun where((w1==saldmoun.TBLOS[6] and c1==saldmoun.KAUOS[6]));
t1._loop parprice{
update saldmoun where((PARPRICE.cPRICEs==saldmoun.nrec)) set saldmoun.TBLOS[6]:=w2,saldmoun.KAUOS[6]:=c2;
inc(n1)};
! Шаблоны проводок ДТ ТХО
t1.delete all PARPRICE;
insert into PARPRICE select 0,hozobor.nrec,0 from hozobor where((w1==hozobor.TBLOS[1] and c1==hozobor.ckauOS[1]));
t1._loop parprice{
update hozobor where((PARPRICE.cPRICEs==hozobor.nrec)) set hozobor.TBLOS[1]:=w2,hozobor.ckauOS[1]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,hozobor.nrec,0 from hozobor where((w1==hozobor.TBLOS[2] and c1==hozobor.ckauOS[2]));
t1._loop parprice{
update hozobor where((PARPRICE.cPRICEs==hozobor.nrec)) set hozobor.TBLOS[2]:=w2,hozobor.ckauOS[2]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,hozobor.nrec,0 from hozobor where((w1==hozobor.TBLOS[3] and c1==hozobor.ckauOS[3]));
t1._loop parprice{
update hozobor where((PARPRICE.cPRICEs==hozobor.nrec)) set hozobor.TBLOS[3]:=w2,hozobor.ckauOS[3]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,hozobor.nrec,0 from hozobor where((w1==hozobor.TBLOS[4] and c1==hozobor.ckauOS[4]));
t1._loop parprice{
update hozobor where((PARPRICE.cPRICEs==hozobor.nrec)) set hozobor.TBLOS[4]:=w2,hozobor.ckauOS[4]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,hozobor.nrec,0 from hozobor where((w1==hozobor.TBLOS[5] and c1==hozobor.ckauOS[5]));
t1._loop parprice{
update hozobor where((PARPRICE.cPRICEs==hozobor.nrec)) set hozobor.TBLOS[5]:=w2,hozobor.ckauOS[5]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,hozobor.nrec,0 from hozobor where((w1==hozobor.TBLOS[6] and c1==hozobor.ckauOS[6]));
t1._loop parprice{
update hozobor where((PARPRICE.cPRICEs==hozobor.nrec)) set hozobor.TBLOS[6]:=w2,hozobor.ckauOS[6]:=c2;
inc(n1)};
t1.delete all PARPRICE;
! Шаблоны проводок КТ ТХО
insert into PARPRICE select 0,hozobor.nrec,0 from hozobor where((w1==hozobor.TBLkS[1] and c1==hozobor.ckaukS[1]));
t1._loop parprice{
update hozobor where((PARPRICE.cPRICEs==hozobor.nrec)) set hozobor.TBLkS[1]:=w2,hozobor.ckaukS[1]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,hozobor.nrec,0 from hozobor where((w1==hozobor.TBLkS[2] and c1==hozobor.ckaukS[2]));
t1._loop parprice{
update hozobor where((PARPRICE.cPRICEs==hozobor.nrec)) set hozobor.TBLkS[2]:=w2,hozobor.ckaukS[2]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,hozobor.nrec,0 from hozobor where((w1==hozobor.TBLkS[3] and c1==hozobor.ckaukS[3]));
t1._loop parprice{
update hozobor where((PARPRICE.cPRICEs==hozobor.nrec)) set hozobor.TBLkS[3]:=w2,hozobor.ckaukS[3]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,hozobor.nrec,0 from hozobor where((w1==hozobor.TBLkS[4] and c1==hozobor.ckaukS[4]));
t1._loop parprice{
update hozobor where((PARPRICE.cPRICEs==hozobor.nrec)) set hozobor.TBLkS[4]:=w2,hozobor.ckaukS[4]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,hozobor.nrec,0 from hozobor where((w1==hozobor.TBLkS[5] and c1==hozobor.ckaukS[5]));
t1._loop parprice{
update hozobor where((PARPRICE.cPRICEs==hozobor.nrec)) set hozobor.TBLkS[5]:=w2,hozobor.ckaukS[5]:=c2;
inc(n1)};
t1.delete all PARPRICE;
insert into PARPRICE select 0,hozobor.nrec,0 from hozobor where((w1==hozobor.TBLkS[6] and c1==hozobor.ckaukS[6]));
t1._loop parprice{
update hozobor where((PARPRICE.cPRICEs==hozobor.nrec)) set hozobor.TBLkS[6]:=w2,hozobor.ckaukS[6]:=c2;
inc(n1)}
end.
Исправлено записей: ^.
Не забудьте исправить шаблоны ТХО для отражения изменений!
.endform
Позже "insert into" переделал на простой insert в цикле (в 2 раза быстрей работает).