解决方案: |
UPDATE Ap_Detail
set cInvCode=b.cInvCode,ibvid=b.autoid
From SaleBillVouch a INNER JOIN SaleBillVouchs b
on a.SBVID=b.SBVID inner join ap_detail c on c.ccovouchtype=a.cvouchtype
and c.ccovouchid=a.csbvcode
where c.cInvCode is null and c.cflag=‘ar‘ and c.iflag<3
and c.ccovouchtype in (‘26‘,‘27‘,‘28‘,‘29‘)
go
UPDATE Ap_Detail
set cInvCode=b.cInvCode,ibvid=b.id
From purBillVouch a INNER JOIN purBillVouchs b
on a.pBVID=b.pBVID inner join ap_detail c on c.ccovouchtype=a.cpbvbilltype
and c.ccovouchid=a.cpbvcode
where c.cInvCode is null and c.cflag=‘ap‘ and and c.iflag<3
and c.ccovouchtype in (‘01‘,‘02‘,‘03‘)
go
update ap_detail
set ccode =null
where auto_id=98608
做完上述语句后,可以检验通过了。
0451-82078107
但至于应收结转完和总帐对帐不平的原因,是因为用户核销制单时改过科目造成的。
检查应收应付核销时是否改过科目,具体的语句如下:
select * from ap_detail a
inner join
(select * from ap_detail where cflag=‘ar‘ and ccovouchtype
in (‘26‘,‘27‘,‘28‘,‘29‘,‘r0‘) and cvouchtype in(‘48‘,‘49‘)) b
on a.ccovouchtype=b.ccovouchtype and a.ccovouchid=b.ccovouchid and a.ibvid=b.ibvid
and a.cvouchtype in(‘26‘,‘27‘,‘28‘,‘29‘,‘r0‘)
and a.ccode<>b.ccode
select * from ap_detail a
inner join
(select * from ap_detail where cflag=‘ap‘ and ccovouchtype
in (‘01‘,‘02‘,‘03‘,‘p0‘) and cvouchtype in(‘48‘,‘49‘)) b
on a.ccovouchtype=b.ccovouchtype and a.ccovouchid=b.ccovouchid and a.ibvid=b.ibvid
and a.cvouchtype in(‘01‘,‘02‘,‘03‘,‘p0‘)
and a.ccode<>b.ccode
|